Import bug: Module executed twice when imported!

Georg Brandl g.brandl-nospam at gmx.net
Fri Jun 30 23:20:37 CEST 2006


Peter Maas wrote:

> The docs tell us
> (http://www.python.org/doc/2.4.2/lib/built-in-funcs.html):
> 
> ------------------------- begin -------------------------------
> execfile(filename[, globals[, locals]])
> 
> This function is similar to the exec statement, but parses a file
> instead of a string. It is different from the import statement in that
> it does not use the module administration -- it reads the file
> unconditionally and does not create a new module.
> ------------------------- end ---------------------------------
> 
> I claim this as a well documented (and thus exspectable) Python behaviour.
> execfile() just executes a file unconditionally without searching in
> sys.modules. That's its purpose, otherwise it would be a synonym of
> the import statement.

This has nothing directly to do with the "problem" since the seemingly
double imported module is not the one that's execfile'd.

Georg



More information about the Python-list mailing list