load a class dynamically

Emile van Sebille emile at fenx.com
Sat Dec 1 04:04:36 CET 2001

"Jeremy Lowery" <jslowery at hotmail.com> wrote in message
news:OqXN7.31025$8n4.2064260 at e3500-atl1.usenetserver.com...
> I know that implementing this may be a little bit of work, but could
> point me in the right direction?
> Have a text file that only contains a class definition, or just a string
> the sake of simplicity.
> str = "class myClass:\n\tdef __init__(self):\n\t\tself.v = 1"
> #the magical code goes here.
> obj = myClass()
> # of course, it doesn't have to be called like that, but to
> #get the ability to instantainate that class.

What's wrong with importing the file?


Emile van Sebille
emile at fenx.com


More information about the Python-list mailing list