[issue6472] Inconsistent use of "iterator" in ElementTree doc & diff between Py and C modules
Milko Krachounov
report at bugs.python.org
Sat Dec 5 14:19:12 CET 2009
Milko Krachounov <python at milko.3mhz.net> added the comment:
This isn't just a documentation issue. A function named getiterator(),
for which the docs say that it returns an iterator, should return an
iterator, not just an iterable. They have different semantics and can't
be used interchangeably, so the behaviour of getiterator() in
ElementTree is wrong. I was using this in my program:
iterator = element.getiterator()
next(iterator)
subelement = next(iterator)
Which broke when I tried switching to ElementTree from cElementTree,
even though the docs tell me that I'll get an iterator there.
Also, for findall() and friends, is there any reason why we can't stick
to either an iterator or list, and not both? The API will be more clear
if findall() always returned a list, or always an iterator, regardless
of the implementation. It is currently not clear what will happen if I do:
for x in tree.findall(path):
mutate_tree(tree, x)
----------
components: +Library (Lib)
nosy: +milko.krachounov
type: -> behavior
versions: +Python 2.6, Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6472>
_______________________________________
More information about the Python-bugs-list
mailing list