PEP 276 -- What else could iter(5) mean?

Bernhard Herzog bh at intevation.de
Thu Mar 7 06:19:41 EST 2002


James_Althoff at i2.com writes:

> [James Althoff]
> > Can you suggest a less contrived example that might be a problem?
> [Bernhard Herzog]
> > x, = 1
> >
> > would assign 0 to x instead of raising an error.
> 
> Agreed.  Note that this example has been in the PEP from the beginning.

Indeed. It's been a while since I read that pep :)

The pep doesn't say anything about the other contexts in which iterators
are used (except for the sequence unpacking above).

With iterable integers:

>>> list(4)
[0, 1, 2, 3]
>>> tuple(4)
(0, 1, 2, 3)
>>> max(4)
3
>>> min(4)
0
>>> filter(None, 4)  # also for map and reduce
[1, 2, 3]
>>> L = []   
>>> L.extend(3)
>>> L
[0, 1, 2]
>>> zip(3)
[(0,), (1,), (2,)]

Do we really want all of these new behaviors?

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                               http://mapit.de/



More information about the Python-list mailing list