PyMeld
15th May 2003
PyMeld is a concrete implementation of something I’ve been thinking about for months: A template system that takes an XHTML page as a template and manipulates it based on cloning and modifying elements within the template identified using their ID attribute. It’s a very elegant solution that makes good use of Python’s object overloading support to make manipulating templates as intuitive as possible. Maybe the same thing will be possible in PHP once the new overloading functions become part of the standard package.
If you decide to have a play with PyMeld you may run in to the limitation that, because class
is a reserved word in Python, you can’t set the class of an element using the standard page.someElementID.class = "something"
syntax. You can however achieve the same thing using Python’s setattr
built in function: setattr(page.someElementID, 'class', 'something')
. That tip comes courtesy of the module’s author who sorted it out for me within about 10 minutes of my email query.
More recent articles
- AI assisted search-based research actually works now - 21st April 2025
- Maybe Meta's Llama claims to be open source because of the EU AI act - 19th April 2025
- Image segmentation using Gemini 2.5 - 18th April 2025