xml with python <-> python deprecated - why?

Frank Millman frank at chagford.com
Tue Dec 20 13:06:10 CET 2005

Hi all

I need to pass data between a server program and a client program, both
written in Python.

My first thought was to use xml. The server builds up an xml string,
without using any xml tools. The client uses Sax to parse the string
received. Here is an example.

The server passes to the client the widgets required to set up a
screen. This is how it tells it to display a button -

    self.gui += '<button label="%s" ref="%s" enabled="%s"
default="%s"/>' \
        % (label,ref,enabled,default)

This is how the client deals with this -


I have recently read that it is not a good idea to use xml unless it is
a specific requirement, so I changed it to passing a list of

The server code now looks like this -


and the client code looks like this -


Performance and readability are pretty much identical. The second
method results in a slightly longer string.

I am curious. Why is xml frowned upon? Is my new method ok, or is there
a better way?

Frank Millman

More information about the Python-list mailing list