dynamic import

bry at itnisk.com bry at itnisk.com
Fri Jul 23 07:56:42 EDT 2004


Hi,
I'm trying to do a dynamic import of a file that has no problems with it, that
is to say I can import it normally, my sys.path is set to the right folder etc.
but my dynamic import code is not working, this is the problem code:

try:
    import f[0]
except:
    print "not importable"
  
f[0] returns the name of the file I'm importing, so I suppose this is a typing
problem, should I change f[0] to be some other type?

I've also tried 
t = "import " + f[0]
    try:
        eval(t)
    except:
	print "not importable"
        
but I always get "not importable"




More information about the Python-list mailing list