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

Igor Soares ibp.srs at gmail.com
Thu Apr 28 14:00:18 EDT 2011


On 27 abr, 21:29, MRAB <pyt... at mrabarnett.plus.com> wrote:
> 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-st...
>
> > 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.

My mistake...
I got confused with wrong code in IDLE...
I also didn't understand that section ( 6.11 ) at first

Thank you guys for the help



More information about the Python-list mailing list