bpo-31454: Include information about "import X as Y" in tutorial#4041
Conversation
| use it to save typing in interactive sessions. | ||
|
|
||
| If as a user of the module you would like to import a module and make it available | ||
| under a different name within the current namespace you can use ``import as``. |
There was a problem hiding this comment.
The "[...] you can use ``import as``" part can be confusing since import as is not valid Python.
I'd use the following sentence as a base in Doc/reference/simple_stmts.rst:
* If the module name is followed by :keyword:`as`, then the name
following :keyword:`as` is bound directly to the imported module.
There was a problem hiding this comment.
Also, please end the sentence with :: (or add it not the next line):
[...] you can use ``import as``::
>>> import fibo as fib
...or
[...] you can use ``import as``.
::
>>> import fibo as fib
...| 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 | ||
|
|
||
| This is effectively importing the module in the same way that ``import fibo`` | ||
| will do, with the only difference of it being available under a different name. |
There was a problem hiding this comment.
It might be better to explicitly say "[...] being available as ``fib``" (you can use different wording -- I just use it as an example) instead of "[...] being available under a different name".
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @berkerpeksag: please review the changes made to this pull request. |
|
Thanks! I've also incorporated your suggestion from the issue tracker Let me know if it needs any re-wording! |
| This is effectively importing the module in the same way that ``import fibo`` | ||
| will do, with the only difference of it being available as ``fib``. | ||
|
|
||
| It can be also used when utilising the ``from`` keyword with similar effects: |
|
|
||
| :: | ||
|
|
||
| >>> import fibo import fib as fibonacci |
There was a problem hiding this comment.
The first import should read from.
|
|
||
| It can be also used when utilising the ``from`` keyword with similar effects: | ||
|
|
||
| :: |
There was a problem hiding this comment.
Since you ended the previous sentence with "[...] effects:", we can just write
[...] with similar effects::instead of
[...] with similar effects:
::|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @berkerpeksag: please review the changes made to this pull request. |
Previously "It can be also "
|
I made a small change in line 127: from "It can be also ..." to "It can also be .. ". |
|
Thanks @mariocj89 for the PR, and @Mariatta for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6. |
|
Thanks @mariocj89 for the PR, and @Mariatta for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
…ial (pythonGH-4041) (cherry picked from commit fbee882) Co-authored-by: Mario Corchero <mariocj89@gmail.com>
|
GH-5894 is a backport of this pull request to the 3.6 branch. |
…ial (pythonGH-4041) (cherry picked from commit fbee882) Co-authored-by: Mario Corchero <mariocj89@gmail.com>
|
GH-5895 is a backport of this pull request to the 3.7 branch. |
…ial (pythonGH-4041) (cherry picked from commit fbee882) Co-authored-by: Mario Corchero <mariocj89@gmail.com>
|
GH-5896 is a backport of this pull request to the 2.7 branch. |
Add some information about "import as" in the tutorial.
Happy to change the wording!
https://bugs.python.org/issue31454