ElementTree's iter() equivalent in Python2.6

爷,独闯天下 提交于 2019-12-01 03:04:27

Note that iter is available in Python 2.6 (and even 2.5 - otherwise, there'd be a notice in the docs), so you don't really need a replacement.

You can, however, use findall:

def _iter_python26(node):
  return [node] + node.findall('.//*')

Not sure if this is what you are looking for, as iter() appears to be around in 2.6, but there's getiterator()

http://docs.python.org/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.getiterator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!