simple text parser?

Irmen de Jong irmen at
Sun Aug 17 11:36:49 CEST 2003

Brandon J. Van Every wrote:

> Can anyone recommend simple text parsers implemented in Python?

You can use Python's own pickle mechanism to serialize almost
any Python object(s). But you won't be able to read it back
in if you also want to build it in another language such as C#
that you mentioned.

Perhaps you're better off using a simple .ini file structure,
that should be *very* easy to parse in C# (I suspect it has .ini
file parsing support built-in) and Python has the ConfigParser module.

Or you could use a CSV (Comma Separated Values) file format,
that is easily generated and parsed from Python's csv module
and should also be easy to do from other languages.

Alternatively you can go for something like this:


This is perhaps the easiest to create and parse, because in Python,
you just execfile() or eval() the file back in. Warning: if somebody
puts extra Python code in it, that will be executed.

--Irmen de Jong

More information about the Python-list mailing list