Pre-PEP: Dictionary accumulator methods

Roose b at b.b
Sat Mar 19 03:54:06 EST 2005


> Py2.5 is already going to include any() and all() as builtins.  The
signature
> does not include a function, identity or otherwise.  Instead, the caller
can
> write a listcomp or genexp that evaluates to True or False:

Actually I was just looking at Python 2.5 docs since you mentioned this.

http://www.python.org/dev/doc/devel/whatsnew/node3.html

It says min() and max() will gain a key function parameter, and sort()
gained one in Python 2.4 (news to me).

And they do indeed default to the identity in all 3 cases, so this seems
very inconsistent.  If one of them has it, and sort gained the argument even
in Python 2.4 with generator expressions, then they all should have it.

>     any(x >= 42 for x in data)

Not to belabor the point, but in the example on that page, max(L, key=len)
could be written max(len(x) for x in L).

Now I know why Guido said he didn't want a PEP for this... such a trivial
thing can produce a lot of opinions.  : )

Roose





More information about the Python-list mailing list