Generated code that is exec-ed (to simulate import) cannot import os.path??
Michael Hudson
mwh at python.net
Fri Nov 28 06:24:54 EST 2003
Irmen de Jong <irmen at -NOSPAM-REMOVETHIS-xs4all.nl> writes:
> Hello,
> I don't understand why the following doesn't work.
> What I want to do is dynamically import some generated
> Python code and I'm doing this using compile and exec'ing
> it in the dict of a new empty module object.
> That works okay, but as soon as the generated code
> tries do perform certain imports, it fails!
> Certain other imports succeed. Consider this example code:
[snip]
> What's going on? Why can't it find os.path?
Dunno. Two things to try:
1) using new.module instead of the imp function
2) run python -v
Cheers,
mwh
--
CLiki pages can be edited by anybody at any time. Imagine the most
fearsomely comprehensive legal disclaimer you have ever seen, and
double it -- http://ww.telent.net/cliki/index
More information about the Python-list
mailing list