[python-win32] RE: execfile question

magic joe joe_magic at skynet.be
Wed Nov 24 19:08:10 CET 2004


Yes ofcourse it should be def f() but the generated file which is much
larger than this fragment by itself works but when you run it from
execfile() inside an environment without the import it does not. If the file
containing execfile already imported time then it also works.

....

I have a program generating dynamic code which is then launched with :

execfile(file_out)

However generated import statements appear not to work, only the modules
that are imported in the program doing the exec call are recognized.
How can I fix this ? (Well one way is importing everything in the calling
module but that is a little bit ugly and may lead to huge load time )



ie:
file contains:

import time
def f:
    return time.localtime()                  # 43
NameError: global name 'time' is not defined
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.786 / Virus Database: 532 - Release Date: 29/10/2004

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.786 / Virus Database: 532 - Release Date: 29/10/2004



More information about the Python-win32 mailing list