[python-win32] execfile question

Kerry Oliphant koliphant at qwest.net
Tue Nov 23 23:18:53 CET 2004


I have code that does what you are trying to do.  It should work.
I tried your little code snippet and it chokes for me on "def f:" shouldn't
it be "def f():"? Or is that just a typo in your email.

Kerry

-----Original Message-----
From: python-win32-bounces+koliphant=qwest.net at python.org
[mailto:python-win32-bounces+koliphant=qwest.net at python.org]On Behalf Of
magic joe
Sent: Tuesday, November 23, 2004 2:53 PM
To: python-win32 at python.org
Subject: [python-win32] execfile question



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

_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32



More information about the Python-win32 mailing list