This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Include "import as" in tutorial
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.7, Python 3.6, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mariatta Nosy List: Mariatta, berker.peksag, docs@python, mariocj89, miss-islington, nyt, r.david.murray, svenyonson
Priority: normal Keywords: easy, patch

Created on 2017-09-13 15:52 by svenyonson, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4041 merged mariocj89, 2017-10-18 21:38
PR 4195 closed python-dev, 2017-10-31 13:21
PR 5894 merged miss-islington, 2018-02-25 19:12
PR 5895 merged miss-islington, 2018-02-25 19:13
PR 5896 merged miss-islington, 2018-02-25 19:14
Messages (18)
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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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
History
Date User Action Args
2022-04-11 14:58:52adminsetgithub: 75635
2018-02-25 19:38:26miss-islingtonsetmessages: + msg312848
2018-02-25 19:35:54miss-islingtonsetmessages: + msg312847
2018-02-25 19:33:16miss-islingtonsetnosy: + miss-islington
messages: + msg312846
2018-02-25 19:16:37Mariattasetstatus: open -> closed
resolution: fixed
messages: + msg312842

stage: patch review -> resolved
2018-02-25 19:14:22miss-islingtonsetpull_requests: + pull_request5668
2018-02-25 19:13:20miss-islingtonsetpull_requests: + pull_request5667
2018-02-25 19:12:21miss-islingtonsetpull_requests: + pull_request5666
2018-02-25 19:11:14Mariattasetmessages: + msg312838
2018-02-25 18:55:56Mariattasetmessages: + msg312833
2017-11-05 11:55:10berker.peksagsetmessages: + msg305594
2017-11-01 04:06:40berker.peksagsetnosy: + berker.peksag
messages: + msg305356
2017-10-31 13:21:07python-devsetpull_requests: + pull_request4165
2017-10-18 21:38:12mariocj89setkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request4012
2017-10-18 21:29:05mariocj89setnosy: + mariocj89
2017-09-15 20:59:26Mariattasetassignee: docs@python -> Mariatta
messages: + msg302301
2017-09-15 20:28:28nytsetnosy: + nyt
messages: + msg302297
2017-09-15 18:02:40eric.araujosetkeywords: + easy
2017-09-14 19:56:23r.david.murraysetmessages: + msg302202
2017-09-14 18:55:58svenyonsonsetmessages: + msg302198
2017-09-14 17:47:54r.david.murraysetversions: + Python 3.6, Python 3.7
2017-09-14 17:47:46r.david.murraysetstatus: closed -> open
title: Include "import as" in documentation -> Include "import as" in tutorial
messages: + msg302189

resolution: not a bug -> (no value)
stage: resolved -> needs patch
2017-09-14 17:24:54svenyonsonsetmessages: + msg302184
2017-09-14 17:22:12svenyonsonsetmessages: + msg302183
2017-09-13 18:15:08Mariattasetstatus: open -> closed

nosy: + Mariatta
messages: + msg302102

resolution: not a bug
stage: resolved
2017-09-13 16:42:44r.david.murraysetnosy: + r.david.murray
messages: + msg302095
2017-09-13 15:52:20svenyonsoncreate