simple text parser?

Alex Martelli aleaxit at yahoo.com
Sun Aug 17 08:44:02 EDT 2003


Brandon J. Van Every wrote:
   ...
> I'm making a 2D game with a simple "adjacent freeform territories" map.  I
> need to make save files for this.  I figure I could store the data in
> either
> binary or text.  The amount of data to be stored should be small enough
> that
> efficiency and size do not matter.  What does matter, is I don't want to
> spend any time at all on this.  I want something off-the-shelf.
> 
> Can anyone recommend simple text parsers implemented in Python?
> 
> Alternately, doesn't Python have some kind of automagical serialization
> pack/unpack functionality?  How does that work?  I remember reading

As several others appear to have indicated already, cPickle is generally
the best module for serializing your data (e.g. to disk) under the
general conditions you're specifying.  The other suggestions (CSV, XML,
and so forth) were based on misunderstanding your specs as meaning you
needed _interoperability_ between Python and C# versions, which you
have later clarified is not the case.


> something about that in the Python docs awhile ago.  Before you scream
> RTFM, bear in mind that my current plan is to write versions of this game
> in C# /
> .NET and Python / WhateverWidgets simultaneously.  I'm ignorant of both
> platforms, this is an excuse to do a comparo.  And, the whole point of
> moving to higher level language development is to minimize pain.  Asking
> questions here rather than reinventing the wheel is part of that agenda. 
> I want to handle this problem off-the-shelf.

Developing a program under each of two platforms you previously didn't 
know is no doubt a good way to compare several characteristics of those 
platforms.  Out of curiosity -- are you relying on Usenet help, rather
than a manual, for the C# version, too?


Alex





More information about the Python-list mailing list