Converting python object reference to int and back

Terry Reedy tjreedy at udel.edu
Sat Sep 7 18:23:14 EDT 2002


"Martin v. Loewis" <martin at v.loewis.de> wrote in message
news:m38z2e2qef.fsf at mira.informatik.hu-berlin.de...
> Ahmad Baitalmal <ahmad at NOSPAMbitbuilder.com> writes:
>
> > How can I get an id (pointer/reference) from a python object and
then
> > get that object back using that integer?
>
> To get an integer, use the id function. To get the object back,
create
> a dictionary mapping the ids to the real objects.

While this answers the OP's question as presented, it seems pretty
useless (and unlikely to solve the real question not asked).  Since
the 'real objects' are represented internally by the same id used as
the key, such a dict would amount to an identity mapping.

Terry





More information about the Python-list mailing list