building string for __import__()
Agent Drek
drek at MonsterByMistake.Com
Mon Dec 13 16:11:37 EST 1999
I have searched deja, python.org/* and cannot find an answer
to my problem. I'm sure I'm just missing something very simple...
I have three directory attributes:
dirdata = {
'somewhere': '0',
'foo': '1',
'flub': '2'
}
FILE = "/mnt/somewhere" + dirdata['somewhere'] + \
"/foo" + dirdata['foo'] \
"/flub" + dirdata['flub'] \
"/TARGET"
RMDATA = __import__(FILE)
will get me the error:
ImportError: No module named /mnt/somewhere0/foo1/flub2/TARGET
however when I do this from the cmdline:
>>> RMDATA = __import__("/mnt/somewhere0/foo1/flub2/TARGET")
everything works.
The file is called TARGET.py
I think that I don't understand how to build up a proper string to pass on to
__import__()
thanks for any help.
cheers,
=derek
Monster By Mistake Inc > 'digital plumber'
http://www.interlog.com/~drek
More information about the Python-list
mailing list