Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python compared with Xen (for XML)

Reply
Thread Tools

Python compared with Xen (for XML)

 
 
Will Stuyvesant
Guest
Posts: n/a
 
      12-03-2004
Here is a comment on the paper "Programming with Circles,
Triangles and Rectangles" by Erik Meijer, Wolfram Schulte
and Gavin Bierman. Google will find it quickly if you try.

In the paper they introduce Xen, an extension to C# for
better XML support. They show how Lifting, Filtering and
Apply-to-all can be done so much better in C# with Xen.

How is Python, my favorite programming language, doing in
this respect? Let's see:



Python for XML
==============


Lifting
-------

The example:
"bib.books.title"
[[an expression for all titles of books in bib]]

(stuff in double quotes "..." is suggested Xen code from the
article by E.Meijer et al., stuff in double square brackets
[[...]] is the intended meaning. Python code is shown after
>>> , the prompt from the Python interactive interpreter.)


We can do this "Lifting" in Python with list comprehension:
>>> [b.title for b in bib.books]



Filtering
---------

The example:
"bib.books[it.year >= 1998]"
[[An expression for the books from 1998 or later]]

This can also be done with Python list comprehensions.
>>> [b for b in bib.books if b.year >= 1998]



Apply-to-all
------------

The example:
"bib.books.{print it}"
[[print all books: execute a code block for every book
in .books.]]

I would do it like this in Python:

for b in bib.books:
print b

looks much clearer to me than the .{...} stuff. Oh and
maybe the new generator expressions can be used for this,
but they are new to me and I can hardly imagine clearer
syntax. Anyone?

All that is needed for this to work in Python is that you
collect XML attributes in object attributes; and that you
give a name to the XML children of an XML element and put
them as a list into an object attribute with that name. Go
wild and even define new classes for it dynamically, or
beforehand if you have the XML DTD or Schema. Not too hard
a programming exercise; who is first?

As for the other content of the article it is my opinion
that they pay way too much attention to data-models and
types, and then strangle themselves trying to fit one
data-model onto another one, and a statically typed one too
for that! (C#, Java, even Visual Basic is mentioned for
laughing out loud). Better try to get the job done first.

They did this work paid by microsoft.research. I think
microsoft.research better pay some more attention to Python.
Or are they? Are the "competitive edge" rumors true?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Axis Authentication Compared To Python Eddy C Java 0 05-27-2006 04:44 PM
Is python very slow compared to C rtilley Python 51 03-16-2006 06:43 PM
Examples of Python code compared to other languages Nicolas Pernetty Python 2 10-30-2005 09:41 AM
How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python? Christian Seberino Python 30 03-02-2004 02:28 AM
Python + Zope compared to J2EE and .Net Sig Python 3 08-12-2003 09:43 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57