Raymond Hettinger added the comment: > ElementTree class currently supports that, > using the find*() or iter() methods.
That would be great except that ElementTree doesn't actually have an __iter__ method. > Ok, but why? The short answer is that every time I conduct Python training, people routinely trip over this issue. The whole point of the ElementTree package was to have a more pythonic interface than DOM or SAX. I'm sure there are people that argue that the requests module isn't great because it conflates requesting with authentication and password management, but the beauty of requests is that its API matches how people try to use it. The outer ElementTree object is awkward in this regard. I don't see any benefit from having this code fail: from xml.etree.ElementTree import parse catalog = parse('books.xml') for book in catalog: print book.get('id') ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21028> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com