lxml Element boolean check
lxml, python
Solution
The relevant place in the Python documentation: https://docs.python.org/2/library/stdtypes.html#truth-value-testing
The ”truthiness” of an object is determined by either the `__nonzero__()` method or if that does not exist the result of the `__len__()` method. As your element has no child elements, i.e. its length is 0, it is considered `False` as a truth value.
Problem
This code: ``` from lxml.html import fromstring, tostring s = '<span class="left">Whatever</span>' e = fromstring(s) print(tostring(e)) print(bool(e)) ``` outputs: ``` <span class="left">Whatever</span> False ``` Why? How boolean check working in this class? Point me on relevant documentation or code please. ps Im using `lxml` 3.3.5