On Aug 7, 2012 8:41 AM, "Roy Smith" <r...@panix.com> wrote:
>
> On Tuesday, August 7, 2012 9:55:16 AM UTC-4, Ben Finney wrote:
>
> >  The tutorial is misleading on this. It it says plainly:
> >
> >     A module can contain executable statements as well as function
> >     definitions. […] They are executed only the *first* time the module
> >     is imported somewhere.
> >
> >     <URL:http://docs.python.org/tutorial/modules.html>
>
> That's more than misleading.  It's plain wrong.  The example I gave
demonstrates the "print __file__" statement getting executed twice.
>
> The footnote to that is wrong too:
>
> > [1]   In fact function definitions are also ‘statements’ that are
‘executed’; the execution of a
> > module-level function enters the function name in the module’s global
symbol table.
>
> I think what it's supposed to say is "... the execution of a module-level
def statement ..."
>
> > Care to file a documentation bug <URL:http://bugs.python.org/>
> > describing this?
>
> Sure, once I understand how it's really supposed to work :-)
>
> --

Each module only gets imported once. But if the same module can be accessed
as two different names, python doesn't recognize that they are the same
module. Along the same lines, if you create a symlink to the file, you'll
be able to import the same module twice.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to