[BangPypers] ElementTree nodes

Noufal Ibrahim noufal at gmail.com
Sun Oct 25 18:18:22 CET 2009

Hello everyone,
   Does anyone have experience here with elementree? Why does a valid
node evaluate to False?

>>> type(n)
<type 'Element'>
>>> n
<Element 'serial-number' at 0x7f7ecabad7e0>
>>> bool(n)
>>> assert n
Traceback (most recent call last):
  File "<console>", line 1, in <module>

   It's the same BTW for elementTree and the C implementation.
Apparently (atleast with 2.6), the classes are still old-style. What's
the special method to coerce an object into a boolean?



More information about the BangPypers mailing list