Weight Plot Script

Python No Comments »

Per request, I have made the Python script which generates my weight graph available here: graph-weight.py.

Prototyping work application in Python

Python No Comments »

One of the three projects I’m involved with for work is designing a piece of software. I did a lot of thinking about it, wrote it up in my notebook, and then I decided I wanted to prototype some pieces in Python. First, the complaints:

  • It wasn’t made very clear that an external package needed to be installed to parse XML in Python. After all, Python 2.2 comes with a number of pieces in the xml.dom namespace!
  • Python installed some C++ dynamically loaded modules -rwx——. Stupid.
  • Python doesn’t search a set of sane paths for libraries, like /usr/lib/python2.2/… or /usr/local/lib/python2.2/… It only searchs $prefix/lib/python2.2/…. I was able to solve this with by setting the environment variable PYTHONPATH though.
  • PyXML-0.7 (which internally uses expat, I believe) is VERY VERY slow when parsing a XML document. I mean VERY. I don’t think the speed problem is from expat.
  • The XML DOM 2.0 standard is stupid, in that it doesn’t provide an easy way to get all direct children of a node with a given tag name (which I think would be a very common operation!) You can either get the child nodelist and search it yourself, or you can use Element::getElementsByTagName() — but that searches ALL descending elements! It looks like DOM 3 includes XPath in the standard, which will make my life easier.

Now the good:

  • Python rocks! I’ve written bits and pieces in it previously (such as pyrumor), and this prototyping exercise only proved my point: I was insanely productive even compared to Java, and it is just fun. It is a very clean language too.

Note to self: I need to find a way to better manage XML DOM traversal and extraction. Currently the source code for both my work projects is delicately tied into the structure of the XML document, and small changes to the document’s DTD could possibly cause drastic breakage of the code. Maybe DOM 3 + XPath will save me here: It should be easier to maintain a centralized XPath <-> data table. Another consideration is validation — should the application ensure its own concept of validation of the document to see if it can “trust” it?

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in