Nodes do not provide a __nonzero__ method. Therefore, according to standard truth value testing, python will fall back to the __len__ method.
That implies that all leaf nodes are falsy, and all non-leaf nodes are truthy. While this is not a big problem, I think it deserves a sentence in the documentation.
Code that looks like this:
return self.root['users']['chaoflow'] or None
will return None, if the chaoflow user has no child nodes, which is usually not what I want.
Nodes do not provide a
__nonzero__
method. Therefore, according to standard truth value testing, python will fall back to the__len__
method.That implies that all leaf nodes are falsy, and all non-leaf nodes are truthy. While this is not a big problem, I think it deserves a sentence in the documentation.
Code that looks like this:
will return
None
, if thechaoflow
user has no child nodes, which is usually not what I want.