How to Get the Object from String/Label?
Alex
cut_me_out at hotmail.com
Tue Sep 12 13:27:45 EDT 2000
>>>>> "William" == William Djaja Tjokroaminata <billtj at y.glue.umd.edu> writes:
William> I have a problem of converting a string/label to the
William> corresponding object. Say I have an object:
William> class MyObject: def __init__ (self, myName):
William> self.myName = myName
William> myObject = MyObject ('xyz')
William> Now, if I have the string 'myObject', how can I get the
William> real object?
Try something like
theObject = eval(myString)
Alex.
--
Speak softly but carry a big carrot.
More information about the Python-list
mailing list