[py-dev] handling of 'class' attribute by py.xml.html
William McVey
wam at cisco.com
Wed Jun 8 23:18:25 CEST 2005
I needed to be able to construct html elements with the 'class'
attribute, in order to properly style the element with a set of
pre-existing stylesheets. Ordinarily, you would think that this could be
something as simple as:
from py.xml import html
html.div(class="somestyleclass")
This obviously doesn't work because 'class' is a reserved word in
python. I "solved" this using a quick hack in my local copy of the
library by adding a quick hack that maps named parameter 'Class' to
attribute 'class'. It's certainly not elegant, but it is effective. The
diff to py/xmlobj/html.py is attached.
-- William
-------------- next part --------------
A non-text attachment was scrubbed...
Name: html.py-Class-hack.patch
Type: text/x-patch
Size: 546 bytes
Desc: not available
Url : http://codespeak.net/pipermail/py-dev/attachments/20050608/4323eb13/html.py-Class-hack.bin
More information about the py-dev
mailing list