dynamic import

Richard Mertens richard.mertens at wolfi.org
Mon May 26 04:28:11 EDT 2003


i have a python file which i use as library

verb_1.py



host="test"
test1="asdf"
class cConfig:
  def __init__(self):
    	self.x="test"



In my main python file i want to import this file (and his variables) 
dynamic

nr="1"
__import__("verb_"+nr)

print host

but i get the following error message

  File "./komm", line 23, in ?
    print host
NameError: name 'host' is not defined

why ???, how can i solve this problem?







More information about the Python-list mailing list