how to cast an instance id

Greg Ewing see_reply_address at something.invalid
Tue Sep 17 21:13:53 EDT 2002

Eric Texier wrote:

> It there a way to create a new reference of  an object
> from the string representation of its id?

No. Python does not provide a way to do this, because
in general it's impossible -- the original object might
not exist any more.

You'll have to keep a reference to the object and
provide a way to get back to it. E.g. a dictionary
mapping id numbers to objects.

 > Now, I would like to give the user some way to save
 > preference

If you're trying to preserve an object from one

Python session to another, take a look at the
"pickle" module.

Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand

More information about the Python-list mailing list