Stringify object reference?

Alan Kennedy alanmk at hotmail.com
Fri Oct 11 12:25:09 EDT 2002


Hi all,

I'm looking for a way to stringify an object reference, i.e. obtain a
reference to an object and turn it into an ASCII representation (that
can be stored in an attribute in an XML DOM-type structure).

Since there is no standard way of associating "user data" with a DOM
node (or any similar data structure), I can't rely on such schemes,
since I want my code to work with all XML tree type structures.

I could just compute my own unique ID for the object, and use that as a
key into a dictionary which I maintain myself. But that smacks of wheel
re-invention, since python has already gone to the trouble of creating a
unique ID for every object, as I can see when I do things like

Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> o = object()
>>> o
<object object at 0x0078B928>
                  ^^^^^^^^^^

But being able to get at this number depends on the __repr__ and __str__
method implementations for the class in question.

Basically, I'm looking for the python equivalent of a CORBA IOR.

Any suggestions? Or am I missing something completely obvious?

Have a good weekend all,

Regards,

alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/mailto/alan



More information about the Python-list mailing list