473,800 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python compared with Xen (for XML)

Here is a comment on the paper "Programmin g 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.titl e"
[[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.{pri nt 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.resea rch. I think
microsoft.resea rch better pay some more attention to Python.
Or are they? Are the "competitiv e edge" rumors true?

Jul 18 '05 #1
0 1182

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

Similar topics

3
4932
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 work in, the IT managers are wondering about the future of web technologies for our intranets. Currently, we run web applications in many technologies : heavy J2EE (EJB...), light J2EE (JSP), ASP.Net, ASP, PHP, ... Our big IT boss
13
3349
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
7730
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 available modules for such things as OPC/fieldbus communication etc... TIA,
68
5904
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
77
3961
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 reStructuredText source as it is today. Please discuss it here so I can see what issues people may have.
47
2201
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 past couple of months. Of course it's easier, but there's just something about it that makes me keep coming back to it and try to think of new ways to use it. Lately I've started to branch away from the "core" Python and I started learning...
21
1922
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 for some reasons we cannot solicity his help. So we'd like to do is to scrub through the codebase and identify places where the codebase needs improvement, both from styling as well as design. Is there any website that can provide me with...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.