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/026333.html below:

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

[Python-Dev] Single- vs. Multi-pass iterabilityOren Tirosh oren-py-d@hishome.net
Fri, 12 Jul 2002 17:16:26 +0300
On Fri, Jul 12, 2002 at 09:36:22AM -0400, Guido van Rossum wrote:
> > I don't understand what you mean by fragile. I'm not suggesting anything
> > that actually depends on this behavior so I don't see what could break.
> 
> If nothing depends on it, what's the point?

To satisfy my perverted obsession for semantic hygiene, of course!

> That version of the xrange object was broken.

That's exactly my point.  There will be more broken code like this as long 
as people keep confusing iterators and iterables. Making the language 
semantically cleaner should help prevent things like this in the long run.

I remember it was pretty hard to actually convince anyone that xrange was 
broken. When I pointed out that the xrange 'iterator' modified the state 
of the xrange 'container' people responded that it's ok because this 
happens with file objects, too...

> 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.

A file object is an iterator pretending to be a container. For historical
reasons it uses 'readline' instead of 'next' and an empty string instead of
StopIteration but it basically does the same job. A file object is not 
really a container that can produce iterators of itself.

	Oren





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