I thought I understood how import worked...
tjreedy at udel.edu
Tue Aug 7 19:15:37 CEST 2012
On 8/7/2012 11:32 AM, Roy Smith 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.
The last sentence should be more like "They are executed only the
*first* time the module is imported anywhere with a particular name.
(One should avoid importing a module under different names.)
>>  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 :-)
You don't need a final solution to file. Anyway, I think the change
above might be enough.
Terry Jan Reedy
More information about the Python-list