New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invalid conversion xml.etree.ElementTree.Element object to boolean #47445
Comments
Python 2.5.2 (r252:60911, May 7 2008, 15:19:09)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from xml.etree.ElementTree import Element
>>> e = Element('Test', {'attr' : 'value'})
>>> b = not e
>>> print b
True Why i'm getting True here instead of False? |
To quote Python Library Reference, paragraph 3.1:
In [113]: e = Element('foo', {'key': 'value'}) In [114]: len(e) In [115]: not e This is because Element is just a container and acts more like a list. In [116]: e.append(Element('bar', {42: 1337})) In [117]: e.append(Element('baz', {'whatever': 'wherever'})) In [118]: len(e) In [119]: not e In conclusion, this just doesn't look like a bug to me. You could try |
Indeed, this is not a bug, although it can be misleading. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: