serializable object references

Daniel Nogradi nogradi at gmail.com
Sun Apr 22 16:25:08 CEST 2007


> Is it possible to convert an object into a string that identifies the
> object in a way, so it can later be looked up by this string.
> Technically this should be possible, because things like
>
> <__main__.Foo instance at 0xb7cfb6ac>
>
> say everything about an object. But how can I look up the real object,
> when I only have this string?
>
> I know such a thing can be achieved with a dictionary that holds
> reference-object pairs. Is there another way?


There is the pickle module for serializing objects into strings:
http://docs.python.org/lib/module-pickle.html

If you need to store objects and later look them up by some key I
would recommend using a database. There are plenty:
http://docs.python.org/lib/persistence.html

HTH,
Daniel



More information about the Python-list mailing list