[Python-Dev] Small any/all enhancement (original) (raw)
Bob Ippolito bob at redivi.com
Tue Dec 27 23:56:31 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 5:48 PM, Valentino Volonghi aka Dialtone wrote:
On Tue, Dec 27, 2005 at 01:50:37PM -0800, Alex Martelli wrote:
I'll answer here for all the people who kindly answered.
Why would that be better than any(o.someattribute for o in someobjects) ? I think it's because lately I've been using common lisp a lot and the approach with the test function is pretty common there. Of course I already knew all the alternatives using map and the generator expression, but I felt like mine was clearer for a reader, this is probably true but not enough to justify the change.
I think that generator/list expressions are more common practice than
attrgetter/itemgetter, so I'm not even sure it's clearer.
I don't see the harm in a "key" argument like sorted has, but without
a key argument it could be extended to take more arguments like max/
min do for convenience. e.g. any(a, b, c) instead of any((a, b, c)).
-bob
- Previous message: [Python-Dev] Small any/all enhancement
- Next message: [Python-Dev] Small any/all enhancement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]