[Python-ideas] Introducing where clauses
Ben Finney
ben+python at benfinney.id.au
Mon Jun 22 13:01:07 CEST 2009
Andrey Popp <8mayday at gmail.com> writes:
> Reading discussion on python-ideas about "Accessing the result of
> comprehension's expression from the conditional", I've came to the
> idea of where clauses, similar to Haskell's.
>
> This solves the problem of recalculating of value multiple times. For
> example, in the following expression:
>
> [(f(x), f(x)) for x in some_iterable if f(x) < 2]
New syntax isn't necessary to solve the above stated problem. For
example, the following existing syntax is also a solution::
[(y, y) for y in (f(x) for x in some_iterable) if y < 2]
For the proposed new syntax to be accepted, it would need to be somehow
significantly superior to the existing syntax. Can you demonstrate how
it's superior?
--
\ “I took a course in speed waiting. Now I can wait an hour in |
`\ only ten minutes.” —Steven Wright |
_o__) |
Ben Finney
More information about the Python-ideas
mailing list