Accessing Objects Based On Their ID

Diez B. Roggisch deetsNOSPAM at web.de
Tue Feb 15 06:43:29 EST 2005


> Given the ID of an object, is there a way to access it?  For example,
> if we have the ID of a class instance, is there a way to invoke its
> methods and attributes knowning only that ID?  Similarly, if we have the
> ID of a function, is there a way to call it?

No. 

> This comes up because of an implementation I had in mind wherein I
> would store the IDs of a notionally linked-list of objects - but without
> the link - I just want to store their IDs in the desired order.  But
> later, when I want to actually use the objects I need a way to get from ID
> back to something accessible in the namespace...

Why only the id? A list only stores a reference to the object anyway - no
copy of it. So you don't gain anything by using the id.
-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list