Convert obejct string repr to actual object
Mark.English at rbccm.com
Fri Oct 12 18:41:19 CEST 2007
> From: Tor Erik Sønvisen
> Date: October 8th 2007
> I've tried locating some code that can recreate an object from
> it's string representation...
On a related note I've wondered about this:
>>> class Foo(object): pass
>>> f = Foo()
>>> s = repr(f)
'<__main__.Foo object at 0x007CBAB0>'
So how do I get f back from s ?
Obviously this is open to abuse. I just wondered if a mechanism existed short of writing
a C-extension which parses that string, casts the hex number to a PyObject *, INCREFs it,
and gives it back...
This email is intended only for the use of the individual(s) to whom it is addressed and may be privileged and confidential.
Unauthorised use or disclosure is prohibited.If you receive This e-mail in error, please advise immediately and delete the original message.
This message may have been altered without your or our knowledge and the sender does not accept any liability for any errors or omissions in the message.
More information about the Python-list