Generated code that is exec-ed (to simulate import) cannot import os.path??
Irmen de Jong
irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Fri Nov 28 13:35:01 CET 2003
Peter Otten wrote:
> Python gets confused by the module name "generated.testmodule", when
> a "generated" package does not exist; it seems to look for
> "generated.posixpath" when it should for "os.posixpath" during the import
> of the os module.
Terrific, that was the problem! Thanks a lot Peter!
After changing the module name to 'generated_testmodule' as you
suggested, it works :-)
Perhaps a more structural improvement is possible but I'm happy
with just changing my generated module name to a name that is
not in a (non-existing) package.
> While this works, a helpful error message would be nice when an intermediate
> package is not found.
--Irmen de Jong.
More information about the Python-list