On Thu, Nov 6, 2008 at 12:04 PM, SimonPalmer <[EMAIL PROTECTED]> 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 > -- http://mail.python.org/mailman/listinfo/python-list