• « XML technologies being used in US Social Security Administration pilot project
    • |
    • Main
    • |
    • Interesting article on Business Intelligence that speaks to the use of XQuery for performing real-time queries of BI data »
            • December 02, 2004

              Is everyone EXCEPT me using Python for XML/XSLT development?

            • XML.com: XSLT Web Service Clients

              While a link to this article has undoubtedly reached your RSS/ATOM/RDF reader several times from several sources my reason for linking to it may be a little different. It seems that everywhere I look now someone is mentioning "when I did this with Python" or "heres a Python script that does this..." leading me to believe that I may very well be the last guy on the planet not using Python in XML/XSLT related development.

              Someone, anyone, whomever wants to take the time to tackle this question.... what is it with Python that has me feeling like the last kid picked for dodge ball at recess? I'm not trying to suggest its not a fantastic language, I simply just don't know a thing about it... and it just seems like maybe I need to put a bit of investment of time into learning it. But then again I don't want to spend my time learning a new language only to find out it does'nt do anything all that great and wonderful that I can't already do with a language I already know.

              Comments?

            • Posted by m.david : December 2, 2004 06:02 PM GMT

            Trackback Pings

            TrackBack URL for this entry:
            http://www.xsltblog.com/xslt-blog-mt/mt-tb.cgi/85

            Listed below are links to weblogs that reference Is everyone EXCEPT me using Python for XML/XSLT development?:

            » <XSLT:Blog />: Is everyone EXCEPT me using Python for XML/XSLT development? from Visions of Aestia
            : Is everyone EXCEPT me using Python for XML/XSLT development? M. David Peterson was wondering why people are using Python for XML development. I left the following as a comment on his blog; here it is for the rest of you too lazy to read his commen... [Read More]

            Tracked on December 2, 2004 08:13 PM

            » street fights from street fights
            street fights [Read More]

            Tracked on March 14, 2006 10:32 AM

            Comments

              • First point - there’s nothing special about processing XML/XSLT from Python versus another language. Most likely you’re still going to be using either DOM or SAX to process your data.

                There are three special features of Python that make it attractive in general.

                1) Lists, dictionaries, tuples, and sets are native data types. Once you realize how many lines of code you spend creating and looping through collections in other languages, you’ll really, really appreciate this feature. This is what brought me into the language.

                Most Python XML libraries allow you to write things like: attributeNames = [a.name for a in element.attributes()]

                Actually, they’d let you write something more elegant and interesting, but the point is that identical code in, say, C# would be five or six lines. The result here is an instance of the standard list class.

                2) It is a terse but readable language. This is very important. The line of code above is typical and should be easy to understand no matter what your background. This makes it easy to debug and maintain.

                A lot of people use it for prototyping. I have a fairly complex GUI application I’ve written that is less than 1,000 lines of code. An earlier version in C# was over 8,000 lines and had less than half the functionality.

                3) Classes are first-class citizens. Adding a custom property to an object dynamically in other languages is several lines of not-always-trivial reflection code. In Python, I can write: attributeNames.originalElement = element

                It’s the combination of these three points that make python interesting. Being able to create classes on the fly as XML is read in and write code that uses those classes with no special steps is, I think, one of the big attractions. Add in the fact that all that traversal of nodes can be done using simple, built-in collection types and that’s icing on the cake.

                For the record, http://diveintopython.org/ is great resource for those new to the language, and it includes a chapter on XML.

              • Posted by: John C Barstow at December 2, 2004 08:10 PM
              • Wow! Thanks John! Beyond the information on Python I think I could learn a thing or two from you on how to write detailed descriptions in as few words possible :) Very nice explanation in very few words. Thank you!

              • Posted by: M. David Peterson at December 2, 2004 08:31 PM
              • Hi David - I felt the same as you until a few months ago, perhaps worse, because I’d had a Python book languishing unread on the shelf for nearly a year.

                I’m still certainly no expert on the language, but was able to write useful XML-oriented code after only a day or so looking at the stuff (coming mostly from Java with bits of other things). Once you get past the initial apparent weirdness of the syntax, everything seems outrageously intuitive.

                btw, I’m usually a flashy IDE fan, but have found the minimal IDLE tool that comes with the Python package pretty well adequate so far.

              • Posted by: Danny at December 3, 2004 04:35 AM
              • You didn’t mention that the XML.com article in question goes on to say “Then I realized that I didn’t need Python at all for this.”

                I first learned Python for the same reason I learned many other languages: to patch together calls to code that other people had written to do more difficult tasks. In other words, there were these great libraries, so if I could write the Python equivalent of a main() {} then I could take advantage of those. For example, the win32com.client, which gives you access to all these MS Outlook internals without having to use VB. And most of the main RDF work is done in Python, so a little Python knowledge takes you a long way in RDF (see this other XML.com article).

              • Posted by: Bob DuCharme at December 3, 2004 07:16 AM
              • Hey Danny,

                Oh good! I’m glad I’m not alone on this. Although both your comments, John’s previously, and Bob’s just now push the realization even further that this is something that, when time permits, I need to learn.

                Cheers!

                <M:D/>
                
              • Posted by: M. David Peterson at December 3, 2004 09:27 AM
              • Bob,

                Thanks for the comments! I especially like the addition of “Then I realized that I didn’t need Python at all for this.” The emphasis coming directly from you says a lot! But more than anything it made me laugh :) Laughing is good :))

                Just out of curiosity, with your comments in regards to win32com.client what is your take on Ruby? This is another language I have seen a lot of good press about. Is it something you use at all?

                Thanks again for taking the time to comment!

                Cheers!

                <M:D/>
                
              • Posted by: M. David Peterson at December 3, 2004 09:30 AM
              • Ruby looks neat, but on my list of languages to learn and play with, it ranks a little below Haskell. I only listed my highest priority reasons for learning Python; there’s also Jython, CGIHTTPServer, shelves, dictionaries, and lots of other great built-in data structures.

              • Posted by: Bob DuCharme at December 3, 2004 11:54 AM
              • I am right with you on Haskell! Between becoming more proficient with Lisp and learning Haskell I would probably list those as my two highest priorities for personal focus. None-the-less, it seems Python needs to be moved on up the list…

                Thanks for your input on this! Your’e experience and expertise is something I hold a lot of respect for and am grateful you have taken the time to help me (and anybody reading this) better understand your reasons behind learning these languages and the priority in which you have placed them.

                Cheers!

              • Posted by: M. David Peterson at December 3, 2004 12:16 PM

            Post a comment




            Remember Me?

            (you may use HTML tags for style)

          • © 2005 :: <XSLT:Blog/> (xsltblog.com) is a product of M. David Peterson and FunctionalX Consulting. See Licensing Info Below.
          • Except where otherwise noted, this sites content and source code is licensed under the Attribution License from Creative Commons.