[BangPypers] ElementTree nodes

bhaskar jain bhaskar.jain2002 at gmail.com
Sun Oct 25 20:22:52 CET 2009

On Mon, Oct 26, 2009 at 12:31 AM, Noufal Ibrahim <noufal at gmail.com> wrote:
>>>Can you try this with an element that has zero children? From effbot's
>>>docs, I think that's the difference.

"The boolean interpretation will most likely change in future versions, so
that all elements evaluate to true, also if they have no children."


>>> a = ElementTree.parse("g.xml").getroot()

>>> type(a.getchildren()[0])
<type 'instance'>
>>> bool(a.getchildren()[0])

>>> type(a.getchildren()[0].getchildren()[0])
<type 'instance'>
>>> bool(a.getchildren()[0].getchildren()[0])
>>> a.getchildren()[0].getchildren()[0].getchildren()


More information about the BangPypers mailing list