how to get back an object from its id() value

CTO debatem1 at gmail.com
Wed Apr 8 12:09:03 EDT 2009


> But how do I get a usable reference from the id value?
> For example, if "foo" has a method "bar()", how can I call "foo.bar()"
> from "str(id(foo))" (say, 149466208).

can you just use a weakref instead? It is certainly cleaner than
trying to store id's,
since an id is only guaranteed to be unique for the lifetime of the
object in question,
and the only way I know of correlating id's to objects involves some C-
level trickery.

for completeness- the trickery: http://www.friday.com/bbum/2007/08/24/python-di/



More information about the Python-list mailing list