Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-31454: Include information about "import X as Y" in tutorial#4041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Mariatta merged 4 commits intopython:masterfrommariocj89:import_as
Feb 25, 2018

Conversation

@mariocj89
Copy link
Contributor

@mariocj89mariocj89 commentedOct 18, 2017
edited by bedevere-bot
Loading

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 sinceimport as is not valid Python.

I'd use the following sentence as a base inDoc/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 phraseI 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
ContributorAuthor

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
ContributorAuthor

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 firstimport should readfrom.


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 phraseI 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
ContributorAuthor

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!

mariocj89 reacted with thumbs up emoji

@MariattaMariatta merged commitfbee882 intopython:masterFeb 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 requestFeb 25, 2018
…ial (pythonGH-4041)(cherry picked from commitfbee882)Co-authored-by: Mario Corchero <mariocj89@gmail.com>
@bedevere-bot
Copy link

GH-5894 is a backport of this pull request to the3.6 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestFeb 25, 2018
…ial (pythonGH-4041)(cherry picked from commitfbee882)Co-authored-by: Mario Corchero <mariocj89@gmail.com>
@bedevere-bot
Copy link

GH-5895 is a backport of this pull request to the3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestFeb 25, 2018
…ial (pythonGH-4041)(cherry picked from commitfbee882)Co-authored-by: Mario Corchero <mariocj89@gmail.com>
@bedevere-bot
Copy link

GH-5896 is a backport of this pull request to the2.7 branch.

miss-islington added a commit that referenced this pull requestFeb 25, 2018
…ial (GH-4041)(cherry picked from commitfbee882)Co-authored-by: Mario Corchero <mariocj89@gmail.com>
miss-islington added a commit that referenced this pull requestFeb 25, 2018
…ial (GH-4041)(cherry picked from commitfbee882)Co-authored-by: Mario Corchero <mariocj89@gmail.com>
miss-islington added a commit that referenced this pull requestFeb 25, 2018
…ial (GH-4041)(cherry picked from commitfbee882)Co-authored-by: Mario Corchero <mariocj89@gmail.com>
@mariocj89mariocj89 deleted the import_as branchFebruary 26, 2018 16:44
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@berkerpeksagberkerpeksagberkerpeksag approved these changes

@MariattaMariattaMariatta approved these changes

Assignees

No one assigned

Labels

docsDocumentation in the Doc dirskip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@mariocj89@bedevere-bot@Mariatta@miss-islington@berkerpeksag@the-knights-who-say-ni

[8]ページ先頭

©2009-2025 Movatter.jp