XML pickle

castironpi at gmail.com castironpi at gmail.com
Thu Feb 14 13:11:48 EST 2008


On Feb 14, 12:45 am, Stefan Behnel <stefan... at behnel.de> wrote:
> Hi,
>
> castiro... at gmail.com wrote:
> > Readability of the Pickle module.  Can one export to XML, from cost of
> > speed and size, to benefit of user-readability?
>
> Regarding pickling to XML, lxml.objectify can do that:
>
> http://codespeak.net/lxml/objectify.html
>
> however:
>
> > It does something else: plus functions do not export their code,
> > either in interpreter instructions, or source, or anything else; and
> > classes do not export their dictionaries, just their names.  But it
> > does export in ASCII.
>
> > Pickle checks any __safe_for_unpickling__ and __setstate__ methods,
> > which enable a little encapsulating, but don't go far.
>
> I'm having a hard time to understand what you are trying to achieve. Could you
> state that in a few words? That's usually better than asking for a way to do X
> with Y. Y (i.e. pickling in this case) might not be the right solution for you.
>
> Stefan

The example isn't so bad.  It's not clear that it isn't already too
specific.  Pickling isn't what I want.  XML is persistent too.

XML could go a couple ways.  You could export source, byte code, and
type objects.  (Pickle could do that too, thence the confusion
originally.)

gnosis.xml and lxml have slightly different outputs.  What I'm going
for has been approached a few different times a few different ways
already.  If all I want is an Excel-readable file, that's one end of
the spectrum.  If you want something more general, but still include
Excel, that's one of many decisions to make.  Ideas.

How does lxml export: b= B(); a.b= b; dumps( a )?

It looks like he can create the XML from the objects already.



More information about the Python-list mailing list