[Python-ideas] ElementTree iterparse string

Ryan rymg19 at gmail.com
Wed Aug 7 16:12:10 CEST 2013


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.

Eli Bendersky <eliben at gmail.com> wrote:

>On Tue, Aug 6, 2013 at 6:52 PM, Ryan <rymg19 at gmail.com> wrote:
>
>> ElementTree iterparse only works with file names or file objects.
>What if
>> there was an iterparse for strings? Like iterparsestring or
>iterfromstring
>> or iterstring, etc. Even though the string is stored in memory,
>storing the
>> entire tree along with the string is a major minus, especially since
>a
>> string takes less memory than an ElementTree instance or a root
>element.
>>
>>
>Hi Ryan,
>
>1) This question is more suitable for python-list@ or Stack Overflow
>2) In addition to Antoine's suggestion, note that ET takes file-like
>objects everywhere, which means you can use StringIO. Look at the tests
>in
>Lib/test/test_xml_etree.py for some examples. This is a common idiom in
>Python programming.
>
>Eli

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130807/097db091/attachment.html>


More information about the Python-ideas mailing list