[Python-Dev] Small any/all enhancement (original) (raw)
Alex Martelli aleaxit at gmail.com
Tue Dec 27 22:50:37 CET 2005
- Previous message: [Python-Dev] Small any/all enhancement
- Next message: [Python-Dev] Small any/all enhancement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Dec 27, 2005, at 12:45 PM, Valentino Volonghi aka Dialtone wrote: ...
any(iterable, test=bool) and all(iterable, test=bool) ... any(someobjects, test=operator.attrgetter('someattribute'))
Why would that be better than any(o.some_attribute for o in some_objects) ?
def zerop(x): return x==0
all(someobjects, zerop)
and why would that be better than all(o==0 for o in some_objects) ?
instead of preprocessing the generator with a generator expression before passing it to any/all.
I guess I just don't see the advantage, along any plane, since the
genexp fits so snugly right there inside the any/all's parentheses.
What am I missing?
Alex
- Previous message: [Python-Dev] Small any/all enhancement
- Next message: [Python-Dev] Small any/all enhancement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]