A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-July/026646.html below:

[Python-Dev] Single- vs. Multi-pass iterability

[Python-Dev] Single- vs. Multi-pass iterabilityAndrew Koenig ark@research.att.com
17 Jul 2002 14:08:50 -0400
Guido> Likewise, the file needs a strong ref to the xreadlines,
Guido> otherwise the following would create a new iterator in the
Guido> second for loop, and lose data buffered by the first iterator.

Guido>     f = open(filename)
Guido>     it = iter(f)
Guido>     for i in range(10):
Guido>         it.next()
Guido>     del it
Guido>     for line in f:
Guido>         print line,

Guido> I think I will have to reject Oren's patch because of this, and
Guido> the situation with file iterators will remain as it is: once
Guido> you've asked for the iterator, all operations on the file are
Guido> unsafe, and the only way to get back to using the file is to
Guido> abandon the file and do an absolute seek on the file.

This implies that you don't expect the code above to work correctly, right?

-- 
Andrew Koenig, ark@research.att.com, http://www.research.att.com/info/ark




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4