Yes, but this practically is the Python manifesto.
Python 2.6.5 (r265:79063, Oct 28 2010, 20:56:23)
[GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
...
There's an import statement that will print it I believe, but I'm not sure exactly what it is.
numbers.filter( _ % 2 == 0 )
This document is old, so we can probably excuse it... but how many Python folks know that? numbers.filter( _ % 2 == 0 ).map( _ / 2 )
Zen of Python doesn't contain any lambdas (the link from the grandparent http://www.python.org/dev/peps/pep-0020/ ). List Comprehensions are 10 years old http://www.python.org/dev/peps/pep-0202/How do you write:
lambda x, y=1: x+y
lambda *args: reduce(lcm, args)
lambda **kwargs: kwargs.get('a') or kwargs.get('b')
def lcm(a, b):
return a*b // gcd(a, b)
def gcd(a, b):
while b:
a, b = b, a % b
return aIt does indeed mention a lambda in the very first example, if only as a competition with list comprehension syntax. But even Python's list comprehensions look a little dated now.
What do you mean by dated? What new ideas have come up for List comprehension syntax?
(I agree that Lambda should be call fun or fn or \. An implicit _ might also work, though that's somewhat against Python's spirit---c.f. the explicit self in methods.)
The part that bothers me about the list comprehension section is that conflating list comprehension and lambda. Is it telling me that list comprehension is better than map/filter or better than lambda? I don't know. Quiet honestly, in many situations I find:
halves_evens = lambda nums : [i/2 for i in nums if nums % 2 == 0]
to be the cleanest.
And then, in our very first example, there is a use of lambda, a misnomer of a concept Python doesn't really support? My brow furrowed slightly more.
I can't help but feel like these people are celebrating their investment in their tools rather than the virtues of the tools themselves.