<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10px"><div id="yiv5215108722"><div id="yui_3_16_0_1_1450663915441_79758"><div id="yui_3_16_0_1_1450663915441_79757" style="color:#000;background-color:#fff;font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10px;"><div id="yui_3_16_0_1_1450663915441_80273">You could use StringIO and save the output from handle.read in memory. Then you can use the data in StringIO twice; once to parse the XML, and once to save it to disk.</div><div id="yui_3_16_0_1_1450663915441_80293">The easiest solution of course is to simply parse the XML file you have saved. I don't see why that doesn't count as a solution.</div><div id="yui_3_16_0_1_1450663915441_80294">-Michiel<br></div><div id="yiv5215108722yui_3_16_0_1_1450663915441_77657"><span></span></div> <div id="yui_3_16_0_1_1450663915441_79759" class="yiv5215108722qtdSeparateBR"><br clear="none"><br clear="none"></div><div class="yiv5215108722yqt7939485453" id="yiv5215108722yqt12777"></div></div></div></div><div class=".yiv5215108722yahoo_quoted"> <div style="font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10px;"> <div style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"> <div dir="ltr"><font face="Arial" size="2"> On Saturday, December 19, 2015 7:09 PM, "c.buhtz@posteo.jp" <c.buhtz@posteo.jp> wrote:<br clear="none"></font></div> <br clear="none"><br clear="none"> <div class="yiv5215108722y_msg_container">I want to use the handle returned by Entrez.efetch() twice.<br clear="none"><br clear="none">First time, write the xml to a file<br clear="none"><br clear="none"> f.write(handle._handle.read())<br clear="none"><br clear="none">But I want to know how much records are in there.<br clear="none"><br clear="none"> records = Entrez.read(handle)<br clear="none"> print(records['Count'])<br clear="none"><br clear="none">This doesn't work here because the handle is "empty" after the first<br clear="none">read()-call.<br clear="none"><br clear="none">Open an read the xml-file would be a resource wasting workaround and not<br clear="none">a solution.<br clear="none">-- <br clear="none">GnuPGP-Key ID 0751A8EC<br clear="none">_______________________________________________<br clear="none">Biopython mailing list - <a rel="nofollow" shape="rect" ymailto="mailto:Biopython@mailman.open-bio.org" target="_blank" href="mailto:Biopython@mailman.open-bio.org">Biopython@mailman.open-bio.org</a><br clear="none"><a rel="nofollow" shape="rect" target="_blank" href="http://mailman.open-bio.org/mailman/listinfo/biopython">http://mailman.open-bio.org/mailman/listinfo/biopython</a><br clear="none"><br clear="none"><br clear="none"></div> </div> </div> </div></div></body></html>