dynamic includes from classes...
Gernot Krause
gkrause at psipenta.com
Fri Sep 13 05:39:02 EDT 2002
Hi
> First, is there a better way than exec to dynamically include a module?
> i.e.
> importvar = "foo"
> exec("from %s import %s" % (importvar, importvar))
(Sorry for my horrible english)
In my mind,its better - you implement a interface class.
If you know the criteria - on script parse time - which class would be used
,
then try this.
DependClass = importvar
class Interface (DependClass):
def __init__(self):
DependClass.__init__(self)
def __del__(self):
DependClass.__del__(self)
...
Gernot
More information about the Python-list
mailing list