[Python-ideas] ElementTree iterparse string

Masklinn masklinn at masklinn.net
Wed Aug 7 16:21:10 CEST 2013


On 2013-08-07, at 16:12 , Ryan wrote:

> Actually, is was a feature suggestion, not a question.
> 
> And, I have the 3.3 version of the docs, so I didn't realize they already added that new feature.

If you're talking about using StringIO, it's not a new feature, it was
already there before elementtree was even merged to the stdlib. Although
it could be clearer, the 2.7 doc for iterparse already notes

> source is a filename or file object containing XML data.

as in other methods & utility functions (parse, ElementTree.parse and
ElementTree.write) "file object" should really be understood as
"file-like object". And more precisely, for parsing it's an object with
a `read(size_hint: int)` method.


More information about the Python-ideas mailing list