For review: PEP 308 - If-then-else expression

Jack Diederich jack at performancedrivers.com
Sun Feb 9 11:24:22 EST 2003


On Sat, Feb 08, 2003 at 04:39:30PM -0800, Paul Rubin wrote:
> "Paul Paterson" <hamonlypaulpaterson at houston.rr.com> writes:
> How about further abuse of colon:
> 
>    f(:expression)
> 
> is short for f(lambda: expression)

I was actually thinking about this yesterday, but with pipes

new       traditional
||foo     labmda:foo
|x|foo    lambda x:foo

IMO this make lambdas more readable, and list comprehensions could DIE
map and filters using lambdas would be more readable, and even shorter
than list comps in plain situations

l = [x.guy for (x) in blah]
l = map(|x|x.guy, blah)

l = [x.guy for (x) in blah if x.guy < 7]
l = map(|x|x.guy, filter(|x|x.guy < 7, blah))

-jackdied





More information about the Python-list mailing list