Skip to content

Conversation

@mariocj89
Copy link
Contributor

@mariocj89 mariocj89 commented Oct 18, 2017

Add some information about "import as" in the tutorial.

Happy to change the wording!

https://bugs.python.org/issue31454

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``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

@bedevere-bot
Copy link

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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@mariocj89
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@berkerpeksag: please review the changes made to this pull request.

@mariocj89
Copy link
Contributor Author

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:keyword:`from`


::

>>> import fibo import fib as fibonacci
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first import should read from.


It can be also used when utilising the ``from`` keyword with similar effects:

::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you ended the previous sentence with "[...] effects:", we can just write

[...] with similar effects::

instead of

[...] with similar effects:

::

@bedevere-bot
Copy link

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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@mariocj89
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@berkerpeksag: please review the changes made to this pull request.

Previously "It can be also "
@Mariatta
Copy link
Member

I made a small change in line 127: from "It can be also ..." to "It can also be .. ".
Once all CI passed we can merge it. Thanks!

@Mariatta Mariatta merged commit fbee882 into python:master Feb 25, 2018
@miss-islington
Copy link
Contributor

Thanks @mariocj89 for the PR, and @Mariatta for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @mariocj89 for the PR, and @Mariatta for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 25, 2018
…ial (pythonGH-4041)

(cherry picked from commit fbee882)

Co-authored-by: Mario Corchero <mariocj89@gmail.com>
@bedevere-bot
Copy link

GH-5894 is a backport of this pull request to the 3.6 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 25, 2018
…ial (pythonGH-4041)

(cherry picked from commit fbee882)

Co-authored-by: Mario Corchero <mariocj89@gmail.com>
@bedevere-bot
Copy link

GH-5895 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 25, 2018
…ial (pythonGH-4041)

(cherry picked from commit fbee882)

Co-authored-by: Mario Corchero <mariocj89@gmail.com>
@bedevere-bot
Copy link

GH-5896 is a backport of this pull request to the 2.7 branch.

miss-islington added a commit that referenced this pull request Feb 25, 2018
…ial (GH-4041)

(cherry picked from commit fbee882)

Co-authored-by: Mario Corchero <mariocj89@gmail.com>
miss-islington added a commit that referenced this pull request Feb 25, 2018
…ial (GH-4041)

(cherry picked from commit fbee882)

Co-authored-by: Mario Corchero <mariocj89@gmail.com>
miss-islington added a commit that referenced this pull request Feb 25, 2018
…ial (GH-4041)

(cherry picked from commit fbee882)

Co-authored-by: Mario Corchero <mariocj89@gmail.com>
@mariocj89 mariocj89 deleted the import_as branch February 26, 2018 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants