py2exe and dynamic modules
peter at engcorp.com
Mon Jun 9 22:18:36 CEST 2003
"Uwe C. Schroeder" wrote:
> The problem is, that I don't use a normal "import blah" statement, since I
> don't know the name yet. AFAIK py2exe actually creates a dict of modules t
> load, so if it doesn't find it at compile time, it's still in the dict -
> making it possible to do a later import. If the module wasn't specified at
> compile time it won't be found.
Oops, I saw that part, but just didn't think clearly enough when I replied.
Let me try again:
File imptest.py, compiled with py2exe as imptest.exe:
filename = sys.argv
mod = __import__(filename)
print 'test failed!'
File importme.py, stored in c:/temp, containing
return 'test OK!'
Run imptest.exe from a directory other than c:/temp:
"test OK" results.
Looks like it works... (I'm doing this test first... what did I do
wrong this time? :-)
More information about the Python-list