[Python-Dev] PEP 3142: Add a "while" clause to generator expressions

Vitor Bosshard algorias at yahoo.com
Mon Jan 19 19:22:51 CET 2009

----- Mensaje original ----
> De: Gerald Britton <gerald.britton at gmail.com>
> Para: Terry Reedy <tjreedy at udel.edu>
> CC: python-dev at python.org
> Enviado: lunes, 19 de enero, 2009 15:03:47
> Asunto: Re: [Python-Dev] PEP 3142: Add a "while" clause to generator expressions
> Duly noted and thanks for the feedback!  (just what I was looking for
> actually).  I do disagree with the idea that the proposal, if
> implemented, would make Python harder to learn.  Not sure who would
> find it harder.  Having to find and use takewhile was harder for me.
> I still find that one counter-intuitive.  I would have expected the
> parameters in the reverse order (take something, while something else
> is true).  Tripped me up a few times, which got me thinking about an
> alternative.

Are you even sure the list comprehension doesn't already shortcut evaluation?

This quick test in 2.6 hints otherwise:

>>> a = (i for i in range(10) if i**2<10)
>>> a.next()
>>> a.next()
>>> a.next()
>>> a.next()
>>> a.next()
Traceback (most recent call last):
  File "<pyshell#32>", line 1, in <module>

      ¡Todo sobre la Liga Mexicana de fútbol! Estadisticas, resultados, calendario, fotos y más:&lt;

More information about the Python-Dev mailing list