Is there a human readable dump format for objects ? As opposed to pickling ?
It doesn't necessarily have to be XML - in fact i'd prefer if it wasn't ;) -
but ISTR an XML dump library.
Chris Stiles wrote:[color=blue]
> Is there a human readable dump format for objects ? As opposed to pickling ?
> It doesn't necessarily have to be XML - in fact i'd prefer if it wasn't ;) -
> but ISTR an XML dump library.
>[/color]
Chris Stiles <chris@example. org> wrote previously:
|Is there a human readable dump format for objects ? As opposed to
|pickling ? It doesn't necessarily have to be XML - in fact i'd prefer
|if it wasn't ;) - but ISTR an XML dump library.
Another poster pointed to YAML, which is a good format. If you want
XML, however, I have gnosis.xml.pick le in Gnosis Utilities.
Certainly YAML is a lot less verbose (but also in a way less explicit).
The method 'yaml.dump()' is misnamed, however, it should have an 's' at
the end.
However, notice this:
[color=blue][color=green][color=darkred]
>>> class NewSomething(ob ject):[/color][/color][/color]
... def __init__(self):
... self.tup = (1,2,3)
... self.dct = {1.4:5.6,7.8:9. 0}
... self.str = "Spam and eggs"
...[color=blue][color=green][color=darkred]
>>> o2 = NewSomething()
>>> print yaml.dump(o2)[/color][/color][/color]
--- <__main__.NewSo mething object at 0x2abbcc>
YAML is lossy in regard to Python types. Some other languages supported
by the YAML format do not have the list/tuple distinction, but since
Python does, usually you want to keep it (which gnosis.xml.pick le does).
Yours, David...
--
mertz@ | The specter of free information is haunting the `Net! All the
gnosis | powers of IP- and crypto-tyranny have entered into an unholy
..cx | alliance...idea s have nothing to lose but their chains. Unite
| against "intellectu al property" and anti-privacy regimes!
-------------------------------------------------------------------------
Comment