Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4172

Re: I think I found a mistake in the official language reference documentation -- or I am missing somethig???

Date 2011-04-28 01:29 +0100
From MRAB <python@mrabarnett.plus.com>
Subject Re: I think I found a mistake in the official language reference documentation -- or I am missing somethig???
References <a24d01a0-35bb-42c3-8aa5-36242e952694@l18g2000yql.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.915.1303950561.9059.python-list@python.org> (permalink)

Show all headers | View raw


On 27/04/2011 21:02, Igor Soares wrote:
> Reading the section "6.11. The import statement"
> http://docs.python.org/py3k/reference/simple_stmts.html#the-import-statement
>
> I found:
> """
> Import statements are executed in two steps: (1) find a module, and
> initialize it if necessary; (2) define a name or names in the local
> namespace (of the scope where the import statement occurs).
> (...)
> The first form (without from) repeats these steps for each identifier
> in the list. The form with from performs step (1) once, and then
> performs step (2) repeatedly.
> """
> In the last sentence, isn't it the opposite?
> With the "from" form it would find/initialize all the modules and
> define just the name after "from".
> Or am I missing something?????

The "from" form is like:

     from monty import spam, eggs

The steps are:

1. find module "monty", and initialize it if necessary

2. define name "spam" in the local namespace

3. define name "eggs" in the local namespace

Also note that the name "monty" itself never enters the local namespace.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

I think I found a mistake in the official language reference documentation -- or I am missing somethig??? Igor Soares <ibp.srs@gmail.com> - 2011-04-27 13:02 -0700
  Re: I think I found a mistake in the official language reference documentation -- or I am missing somethig??? Ken Watford <kwatford+python@gmail.com> - 2011-04-27 17:21 -0400
    Re: I think I found a mistake in the official language reference documentation -- or I am missing somethig??? Igor Soares <ibp.srs@gmail.com> - 2011-04-27 15:36 -0700
  Re: I think I found a mistake in the official language reference documentation -- or I am missing somethig??? MRAB <python@mrabarnett.plus.com> - 2011-04-28 01:29 +0100
    Re: I think I found a mistake in the official language reference documentation -- or I am missing somethig??? Igor Soares <ibp.srs@gmail.com> - 2011-04-28 11:00 -0700

csiph-web