Personal data serialization modules
I finally managed to salvage my python work from my old hard drive, and these are the two modules I referred to in my previous post:xmlValue
From that page:
This is a set of (two) modules which convert between a simple xml specification and nested Python dictionaries, making basic data easily writable and retrievable. The result is essentially very basic serialization that is language independent and human readable.Again there are numerous serialization modules (Pickle, marshal, etc.), and I'm certain someone has made on that uses XML, however I was hoping to use these two that I've written (the data conversion is literally effortless). I know we're supposed to announce any personal libraries we plan to use far ahead of time, so if anyone has any qualms with these modules being used, I certainly won't complain. :)
(log in to comment)
Comments
Python Style Guide gives the answer to that:
The _single_leading_underscore: weak "internal use" indicator (e.g. "from M import *" does not import objects whose name starts with an underscore).So it's an indicator for stuff that's not meant to be used from the outside.
This is kinda a pet gripe for me. People marking stuff as "internal" are usually overly paranoid in my book :)
>>> import xmlValueWriter >>> data = {} >>> data['name'] = "Daniel Bickett" >>> data['team'] = "heureusement" >>> data['nestedDict'] = {'testing' : 1, 'blah': 4123} >>> data['friends'] = {"Mac":"Graphics"} >>> xmlValueWriter.write("entrant.xml", "Entrant", data) Writing 'Entrant' to file 'entrant.xml'... Done!Produces this: entrant.xml
Then...
>>> import xmlValueParser >>> xmlValueParser.parse("entrant.xml") : Loading xml value file: entrant.xml {'nestedDict': {'blah': '4123', 'testing': '1'}, 'friends': {'Mac': 'Graphics'}, 'name': 'Daniel Bickett', 'team': 'heureusement'}Obviously there are a few things that need to be fixed, now that I go through and use it again. There are output artifacts that need to be done away with. Also, it seems that in my MUD I never needed a boolean field (or else I was content with using '1' and '0' rather than creating a new feature for the module), so that hasn't been added :) Anyway, there it is, if it does need a bit of cleaning up.
richard on 2006/03/22 23:10:
That's all pretty simple stuff, so I have no problem with it. I'd like to see some usage documentation though :)On a stylistic note, what's with the leading underscores in the function names?