[help]How to load a class dynamic?
Gerrit Holl
gerrit at nl.linux.org
Tue May 13 04:21:21 EDT 2003
dolephi9080 schreef op dinsdag 13 mei om 09:37:55 +0000:
> Suppose I have some 3 party Modules, and In my program, I don't know
> what is the 3 party classes are, but I can find the name from the 3
> party's Module.
> it provide a manifest, it has a line classname =
> "mypackage.mymodule.MyClass"
> now my program read this line, and how to instance the class from
> this string?
You can use exec for that:
6 >>> exec "a=A()"
7 >>> a
<__main__.A instance at 0x400c7aac>
yours,
Gerrit.
--
269. If he hire an ass for threshing, the hire is twenty ka of corn.
-- Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
http://www.sp.nl/
More information about the Python-list
mailing list