accept xml instead of plain Python text?

John Roth newsgroups at jhrothjr.com
Sun Apr 11 17:38:02 EDT 2004


"Edward K. Ream" <edreamleo at charter.net> wrote in message
news:107jc0h6r5c3g3d at corp.supernews.com...
> 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.  I can think of several
reasons
> why this would be _inconvenient_ for the Python community.  Foremost among
> them would be that no plain-text tool would work with xml'zed Python.
>
> Has the subject been discussed in the Python community? If so, where?  I
> suspect this is a bad (or cumbersome) idea, but I'd like to be sure :-)
> Thanks.

I'm not aware of it being discussed, but as far as I can tell,
it shouldn't be all that hard to do if you're willing to do some
work. Look at Section 19 in the Python Library Reference,
plus the parser writeup in 18.1 and marshal in 3.19 (the section
numbers change when the doc changes.)

You should be able to convert an XML format of your
design to an AST and compile it to bytecodes; likewise
you should be able to generate an XML file from the AST.

The only thing that seems to be missing is a routine to actually
build a .pyc or .pyo file. I'm not sure how much work that
would be, but you might get some clues from 18.10 - dis
(the python disassembler)

While I'm quite skeptical of the utility of XML as a
programming language format, your reference 2 does
make some interesting points. You might also check
out the IO language, where the parse tree is the definitive
form of the language, and the actual text form is represented
as only one way to do it.

As innumerable project managers have discovered,
the best way to find the *real* requirements is to get
something out there and find out what real users say
about it.

John Roth


> Edward





More information about the Python-list mailing list