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

Created on 2017-09-13 15:52 by svenyonson, last changed 2017-09-15 20:59 by Mariatta.

Messages (10)
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 Wijaya (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 Wijaya (Mariatta) * (Python committer) Date: 2017-09-15 20:59
I might know an aspiring contributor who can work on this. Assigning to myself.
History
Date User Action Args
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:40merwoksetkeywords: + 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 ->
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