accept xml instead of plain Python text?

"Martin v. Löwis" martin at v.loewis.de
Sun Apr 11 18:39:25 EDT 2004


Edward K. Ream wrote:
> I am wondering whether that has been any discussion of a project like the
> following in the Python world:
> 
> - jezix http://www.tel.fer.hr/users/mtopol/jezix/
> - javaml http://sourceforge.net/projects/javaml/
> 
> The general idea is that it would sometimes be nice to be able to feed xml
> to the Python parser instead of plain text.

This comes up every now and then on the XML SIG, and the responses are
typically reserved. I tend to respond with two observations:
1. What advantage would you get?
2. How exactly should the XML look like? The simplest approach I can
    think of is

<python>
def test():
     """Test this module.

     A hodge podge of tests collected here, because they have too many
     external dependencies for the regular test suite.
     """

     import sys
     import getopt
     opts, args = getopt.getopt(sys.argv[1:], 'd')
     dl = 0
     for o, a in opts:
         if o == '-d': dl = dl + 1
     host = 'www.python.org'
</python>

Nice XML; if you use CDATA sections, you don't even need to markup
less-than characters.

Regards,
Martin




More information about the Python-list mailing list