Message 357682 - Python tracker (original) (raw)
Stefan's arguments looked reasonable to me. I supported deprecating Element.bool. This was an old plan, although we failed with deprecation in the C implementation (this is not the first oversight in deprecations in ElementTree).
But there is a problem: removing bool will not change the value of bool(element). It will still return False for an Element without children, because bool() falls back to len if bool is not defined, and Element.len is defined. So we will need either to define Element.bool always returning True, and this will be the first case when bool and len return inconsistent values, or to deprecate len (and perhaps getitem) that goes too far from the initial plan.
So now I am not sure. Making Element.bool always returning True or raising an exception could help to fix some bugs in user code. But this differs from common behavior of sequence-like types in Python. On other hand, we have a precedence: bool(NotImplemented) raises an exception now (this also can save from common errors).
When I started to write this message I was -0 for changing Element.bool. Now I am +0, after considering all arguments that came in my mind, but still have doubts. Can we ask some of the language ideologues?