A RetroSearch Logo

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

Search Query:

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

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

[Python-Dev] Single- vs. Multi-pass iterability [Python-Dev] Single- vs. Multi-pass iterabilityKa-Ping Yee ping@zesty.ca
Mon, 15 Jul 2002 16:16:51 -0700 (PDT)
On Fri, 12 Jul 2002, Guido van Rossum wrote:
> I don't see what's wrong with the file object.  Iterating over a file
> changes the file's state, that's just a fact of life.

That's exactly the point.  Iterators and containers are different.
Walking over a container shouldn't mutate it, whereas an iterator
has mutable state independent of the container.

The key problem is that the file's __iter__ method returns something
whose state depends on the file, thus breaking this expectation.
Either __iter__ should be implemented to fulfill its commitment, or
there shouldn't be an __iter__ method on files at all.

I'm not suggesting that the semantics of files themselves are "broken"
or have a "wart" that needs to be fixed -- merely that we should decide
on a place for files to live in our world of containers and iterators,
so we can set and maintain consistent expectations.


-- ?!ng





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