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

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

[Python-Dev] Re: Single- vs. Multi-pass iterability [Python-Dev] Re: Single- vs. Multi-pass iterabilityAlex Martelli aleax@aleax.it
Fri, 19 Jul 2002 08:16:34 +0200
On Friday 19 July 2002 12:26 am, Tim Peters wrote:
> > What about:
> >
> >     "...sequences.  Note that the act of looking at an iterator's
> >     elements mutates the iterator."
>
> That doesn't belong in the spec either -- nothing requires an iterator to
> have mutable state, let alone to mutate it when next() is called.

Right, for unbounded iterators returning constant values, such as:

class Ones:
    def __iter__(self): return self
    def next(self): return 1

However, such "exceptions that prove the rule" are rare enough that I
wouldn't consider their existence as forbidding to say _anything_ about
state mutation.  I _would_ similarly say that x[y]=z normally mutates x,
even though "del __setitem__(self, key): pass" is quite legal.  Inserting
an adverb such as "generally" or "usually" should suffice to make even
the most grizzled sea lawyer happy while keeping the information in.


Alex




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