473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Python compared with Xen (for XML)

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?

Jul 18 '05 #1
0 1164

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sig | last post by:
Hi there, Could you help me finding out whether Zope could be a serious technological framework for big corporation (compared to J2EE and ..Net) or not ? In the (quite very) big corporation I...
13
by: Ajay | last post by:
hi! can you call a Python application from a Java program? does this require any additional package to be installed? thanks cheers
26
by: Wolfgang Keller | last post by:
Hello, is it that my know-how to use Google is insufficient or... ....does really noone use Python for industrial control applications? At least I didn't manage to find any publicly...
68
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
77
by: Ben Finney | last post by:
Howdy all, PEP 354: Enumerations in Python has been accepted as a draft PEP. The current version can be viewed online: <URL:http://www.python.org/peps/pep-0354.html> Here is the...
47
by: John Salerno | last post by:
I have to say, I'm having a very enjoyable time learning and using Python. I spent a year playing around with C# and I feel like I learned/know less about it than I do about Python from just the...
21
by: Raj | last post by:
Hi, We just executed a project with Python using TG. The feedback was to use more python like programming rather than C style code executed in Python. The feedback is from a Python purist and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.