Memory addressing

Carsten Haese carsten at uniqsys.com
Fri Apr 27 23:00:06 CEST 2007


On Fri, 2007-04-27 at 12:56 -0700, Simon Berube wrote:
> When you call certain objects __repr__() strings in python you often
> get the : <Object at Memory Address> happen. I am simply trying to
> understand how that information can be used to recreate a certain
> object that failed as per the given purpose of the __repr__()
> functions.

It's not a requirement of repr() that the resulting string be suitable
for recreating the object. For many built-in object types, calling
eval() on their repr() will result in a copy of the object, but in
general eval(repr(obj))==obj will not be true.

> In short, how do I used <Object at Memory Address> strings to recreate
> a an object.

You don't. What you should do instead depends on what you actually need
to do, which you haven't said yet. Do you want to pass an object to
another function, do you want to make a copy of an object, or do you
want to serialize/unserialize an object to send it through time and/or
space?

-Carsten





More information about the Python-list mailing list