flox <la...@yahoo.fr> added the comment: There's many differences between both implementations. I don't know if we can live with them or not.
~ $ ./python Python 3.1.1+ (release31-maint:76650, Dec 3 2009, 17:14:50) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from xml.etree import ElementTree as ET, cElementTree as cET >>> from io import StringIO >>> SAMPLE = '<root/>' >>> IO_SAMPLE = StringIO(SAMPLE) With ElementTree >>> elt = ET.XML(SAMPLE) >>> elt.getiterator() [<Element root at 15cb920>] >>> elt.findall('') # or '.' [<Element root at 15cb920>] >>> elt.findall('./') [<Element root at 15cb920>] >>> elt.items() dict_items([]) >>> elt.keys() dict_keys([]) >>> elt[:] [] >>> IO_SAMPLE.seek(0) >>> next(ET.iterparse(IO_SAMPLE)) ('end', <Element root at 15d60d0>) >>> IO_SAMPLE.seek(0) >>> list(ET.iterparse(IO_SAMPLE)) [('end', <Element root at 15583e0>)] With cElementTree >>> elt_c = cET.XML(SAMPLE) >>> elt_c.getiterator() <generator object getiterator at 0x15baae0> >>> elt_c.findall('') [] >>> elt_c.findall('./') [<Element 'root' at 0x15cf3a0>] >>> elt_c.items() [] >>> elt_c.keys() [] >>> elt_c[:] Traceback (most recent call last): TypeError: sequence index must be integer, not 'slice' >>> IO_SAMPLE.seek(0) >>> next(cET.iterparse(IO_SAMPLE)) Traceback (most recent call last): TypeError: iterparse object is not an iterator >>> IO_SAMPLE.seek(0) >>> list(cET.iterparse(IO_SAMPLE)) [(b'end', <Element 'root' at 0x15cf940>)] ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6472> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com