py2exe and dynamic modules

Peter Hansen peter at
Mon Jun 9 22:54:23 CEST 2003

"Uwe C. Schroeder" wrote:
> Peter Hansen wrote:
> > 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?  :-)
> :-)) You knew the path up front. But I'll probably do just that and install
> the modules in a fixed path, although I don't really like it. But I guess
> it's easier than fiddling around with the  py2exe import stuff.

Don't make it so hard on yourself!  Here's version two, without a
hardcoded path:

import sys
filename = sys.argv[2]
    mod = __import__(filename)
    print mod.test()
    print 'test failed!'

Still works... ;-)


More information about the Python-list mailing list