msg302083 - (view) |
Author: Steve Johnson (svenyonson) |
Date: 2017-09-13 15:52 |
I was wondering if you could do something like fiblib = import fibo or import fibo as fiblib, and low and behold, the "as" variant worked. I find this very useful, and thought it should be part of your documentation on "import" |
|
|
msg302095 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2017-09-13 16:42 |
Where do you find that it is not documented that you would expect it to be? Because 'import' 'as' is certainly documented. |
|
|
msg302102 - (view) |
Author: Mariatta (Mariatta) *  |
Date: 2017-09-13 18:15 |
import as is documented, so I'm closing this unless you have other concerns. Python 3 docs: https://docs.python.org/3/reference/simple_stmts.html#import ``` If the module name is followed by as, then the name following as is bound directly to the imported module ``` Wording is somewhat different in Python 2.7 docs, but it's there: https://docs.python.org/2.7/reference/simple_stmts.html#the-import-statement Thanks. |
|
|
msg302183 - (view) |
Author: Steve Johnson (svenyonson) |
Date: 2017-09-14 17:22 |
In the 2.7 Tutorial, section 6, modules, where it describes the various syntax for using import. > On Sep 13, 2017, at 10:42 AM, R. David Murray <report@bugs.python.org> wrote: > > > R. David Murray added the comment: > > Where do you find that it is not documented that you would expect it to be? Because 'import' 'as' is certainly documented. > > ---------- > nosy: +r.david.murray > > _______________________________________ > Python tracker <report@bugs.python.org> > <https://bugs.python.org/issue31454> > _______________________________________ |
|
|
msg302184 - (view) |
Author: Steve Johnson (svenyonson) |
Date: 2017-09-14 17:24 |
My suggestion was to include this in the 2.7 tutorial, section 6 (modules) where the various syntax is described for import. Most of us don't dig into the reference until we are trying to find something specific. The tutorial is an excellent place to introduce useful but not obvious features of the language. > On Sep 13, 2017, at 12:15 PM, Mariatta Wijaya <report@bugs.python.org> wrote: > > > Mariatta Wijaya added the comment: > > import as is documented, so I'm closing this unless you have other concerns. > > Python 3 docs: https://docs.python.org/3/reference/simple_stmts.html#import > ``` > If the module name is followed by as, then the name following as is bound directly to the imported module > ``` > > Wording is somewhat different in Python 2.7 docs, but it's there: https://docs.python.org/2.7/reference/simple_stmts.html#the-import-statement > > Thanks. > > ---------- > nosy: +Mariatta > resolution: -> not a bug > stage: -> resolved > status: open -> closed > > _______________________________________ > Python tracker <report@bugs.python.org> > <https://bugs.python.org/issue31454> > _______________________________________ |
|
|
msg302189 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2017-09-14 17:47 |
I agree that it would seem reasonable to add this to section 6.1 of the tutorial, since it mentions both import statement variants and the modules "global symbol table", which are the two concepts involved in import as. Would you like to propose a PR? |
|
|
msg302198 - (view) |
Author: Steve Johnson (svenyonson) |
Date: 2017-09-14 18:55 |
I don't know what a PR is, so I'll let you guys handle it if it is OK with you. > On Sep 14, 2017, at 11:47 AM, R. David Murray <report@bugs.python.org> wrote: > > > R. David Murray added the comment: > > I agree that it would seem reasonable to add this to section 6.1 of the tutorial, since it mentions both import statement variants and the modules "global symbol table", which are the two concepts involved in import as. > > Would you like to propose a PR? > > ---------- > resolution: not a bug -> > stage: resolved -> needs patch > status: closed -> open > title: Include "import as" in documentation -> Include "import as" in tutorial > > _______________________________________ > Python tracker <report@bugs.python.org> > <https://bugs.python.org/issue31454> > _______________________________________ |
|
|
msg302202 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2017-09-14 19:56 |
Well, this is all volunteer work. Maybe someone else will feel like doing it :) |
|
|
msg302297 - (view) |
Author: Novel (nyt) |
Date: 2017-09-15 20:28 |
The offending file is here: https://github.com/python/cpython/blob/master/Doc/tutorial/modules.rst Read the developer's guide to learn how to submit your changes to python. https://devguide.python.org/ |
|
|
msg302301 - (view) |
Author: Mariatta (Mariatta) *  |
Date: 2017-09-15 20:59 |
I might know an aspiring contributor who can work on this. Assigning to myself. |
|
|
msg305356 - (view) |
Author: Berker Peksag (berker.peksag) *  |
Date: 2017-11-01 04:06 |
I just reviewed Mario's pull request. Should we mention the "from fibo import fib as fibonacci" syntax too? |
|
|
msg305594 - (view) |
Author: Berker Peksag (berker.peksag) *  |
Date: 2017-11-05 11:55 |
PR 4041 looks good to me. Mariatta, do you have time to look at Mario's patch? Sarthak, thank you for your PR, but a PR was opened 12 days before yours (sorry, I missed it earlier) Would you like to work on another issue? I've just opened bpo-31948 and I'd be happy to review/merge a PR if you have time. Thanks! |
|
|
msg312833 - (view) |
Author: Mariatta (Mariatta) *  |
Date: 2018-02-25 18:55 |
> PR 4041 looks good to me. Mariatta, do you have time to look at Mario's patch? Sorry I just saw this now, months later. Looks good to me. I can merge and backport once the CI passed. Thanks! |
|
|
msg312838 - (view) |
Author: Mariatta (Mariatta) *  |
Date: 2018-02-25 19:11 |
New changeset fbee88244e8921afdb29fde51a9a010a8ae18277 by Mariatta (Mario Corchero) in branch 'master': bpo-31454: Include information about "import X as Y" in Modules tutorial (GH-4041) https://github.com/python/cpython/commit/fbee88244e8921afdb29fde51a9a010a8ae18277 |
|
|
msg312842 - (view) |
Author: Mariatta (Mariatta) *  |
Date: 2018-02-25 19:16 |
Thanks everyone. I've merged Marios's PR. The backport PRs have started and will automerge. |
|
|
msg312846 - (view) |
Author: miss-islington (miss-islington) |
Date: 2018-02-25 19:33 |
New changeset 5a07608d0855e4104e4070328155b52010dec4e7 by Miss Islington (bot) in branch '3.6': bpo-31454: Include information about "import X as Y" in Modules tutorial (GH-4041) https://github.com/python/cpython/commit/5a07608d0855e4104e4070328155b52010dec4e7 |
|
|
msg312847 - (view) |
Author: miss-islington (miss-islington) |
Date: 2018-02-25 19:35 |
New changeset e48e6499bbad56f7cc665efa25ae4847f51dbc38 by Miss Islington (bot) in branch '3.7': bpo-31454: Include information about "import X as Y" in Modules tutorial (GH-4041) https://github.com/python/cpython/commit/e48e6499bbad56f7cc665efa25ae4847f51dbc38 |
|
|
msg312848 - (view) |
Author: miss-islington (miss-islington) |
Date: 2018-02-25 19:38 |
New changeset 76349471adfa4366a92438c88fd05a0e1e94c59b by Miss Islington (bot) in branch '2.7': bpo-31454: Include information about "import X as Y" in Modules tutorial (GH-4041) https://github.com/python/cpython/commit/76349471adfa4366a92438c88fd05a0e1e94c59b |
|
|