Pickle to source code

Benjamin Niemann pink at odahoda.de
Wed Oct 26 05:58:11 EDT 2005


Gabriel Genellina wrote:

> I want to convert from pickle format to python source code. That is,
> given an existing pickle, I want to produce a textual representation
> which, when evaluated, yields the original object (as if I had
> unpickled the pickle).
> I know of some transformations pickle/xml (Zope comes with one such
> tool, gnosis xml is another) so I believe I could build something based
> on them.
> But I dont want to reinvent the wheel, I wonder if anyone knows of a
> library which could do what I want?

If all objects correctly implement the __repr__ method (true for built-in
stuff like list, dict, set...):
Just unpickle it and call repr() on the resulting object.


-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/



More information about the Python-list mailing list