How do I get an object from the id()-identifier?

Mats Sjoberg masjober at abo.fi
Thu May 17 09:21:20 EDT 2001


>> but how do I get the object back if I only have this identifier?
> You cannot, unless you maintain your own dict mapping ids to objects.
> 
> The best way to map ids to objects is to rethink what you really want to
> accomplish until it becomes clear that mapping ids to objects isn't actually
> going to get the job done <0.9 wink>.

	What I want to do is to store a reference to a python object in
	a tag in a normal Tkinter Text widget. Tags cannot be arbitrary 
	objects (as far as I know) so I would have to store the references 
	as the ids of the objects. I have considered using a dictionary
	for this but it doesn't seem that efficient. It would be easier,
	and faster, if I could just get the object directly from the id.
	I might also have many different Text widgets with tags to the
	same object.

Mats Sjöberg



More information about the Python-list mailing list