Michael Abbott wrote: > In article <[EMAIL PROTECTED]>, > Michael Abbott <[EMAIL PROTECTED]> wrote: > >> --- test.py --- >> import imptest >> execfile('subtest.py', dict(__name__ = 'subtest.py')) >> --- imptest.py --- >> print 'Imptest imported' >> --- subtest.py --- >> import imptest >> --- >> >> $ python test.py >> Imptest imported >> Imptest imported >> $ > > I claim this as an unreported (and highly obscure) Python bug.
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. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list