List to Text back to List
Chris Rebert
clp at rebertia.com
Thu Nov 6 15:11:48 EST 2008
On Thu, Nov 6, 2008 at 12:04 PM, SimonPalmer <simon.palmer at gmail.com> wrote:
> Hi, I am looking for a way to convert a List of floating point numbers
> to and from text. I am embedding it in an XML document and am looking
> for a neat way to serialise and de-serialise a list from a text node.
> I can easily write something to do it manually but I wondered whether
> List had native support to go to and from text.
>
> If not List, are there any other collections/arrays that do this?
It's not really a matter of the collection, but more a matter of
serialization format/library.
If you want the serialized representation to be human-readable, use
JSON (http://docs.python.org/library/json.html#module-json).
If that's not a requirement, use pickle
(http://docs.python.org/library/pickle.html#module-pickle).
Both modules can convert simple Python data, such as your list of
floats, to a bytestream and back again.
Cheers,
Chris
--
Follow the path of the Iguana...
http://rebertia.com
>
> TIA
> Simon
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list