Getting a class from its name

j vickroy jim.vickroy at noaa.gov
Tue Aug 20 17:42:01 EDT 2002


How about the eval() function?  For example,

>>> a = str('hi')
>>> a
'hi'
>>> b = eval("str('hi')")
>>> b
'hi'
>>> type(b)
<type 'str'>
>>>

"Henrik Motakef" <henrik.motakef at web.de> wrote in message
news:8765y51azj.fsf at pokey.henrik-motakef.de...
> Hi,
>
> I guess thats an easy one, but somehow I'm blocked.
> How do I get a class given its name (or an object of this class
> ultimatly)?
>
> Say I have the string "xml.dom.Node", how do I use it to make a Node
> object?
>
> tia
> Henrik





More information about the Python-list mailing list