[lxml-dev] ET 1.3

Ian Bicking ianb at colorstudy.com
Wed Sep 12 19:37:00 CEST 2007


I was just reading the ElementTree 1.3 release notes:

   http://effbot.org/zone/elementtree-13-intro.htm

Generally I like the changes.  The change from Element as a factory 
function to Element as a subclassable class (akin to ElementBase), is 
nice -- I never understood why there was a distinction.  Except... 
because "el = Element(tag)" doesn't necessarily mean that "el.__class__ 
is Element"...?

getiterator to iter is a simple seeming change.  Since getiterator 
actually returns an iterable, not an iterator, it's also just a little 
more accurate.  Looks like it also moves to an iterator, not a list.

I don't have much of an opinion on the parser and serializer stuff, 
though I'd love it if there was a proper serializer for HTML (not the 
dumb XSLT-based thing I put in lxml.html).

I notice that elements now give warnings when treated as booleans.  I 
like this a lot, as I've found many bugs in my code where I did "if el" 
where I should have done "if el is not None".  And an element with no 
children doesn't feel falsish at all to me.  I've actually already taken 
to using len(el) to test for children, just because I can't get myself 
to commit to this weird-seeming behavior.


-- 
Ian Bicking : ianb at colorstudy.com : http://blog.ianbicking.org
             : Write code, do good : http://topp.openplans.org/careers


More information about the lxml-dev mailing list