[Python-Dev] Any reason that any()/all() do not take a predicate argument? (original) (raw)
Mikhail Glushenkov bbman at mail.ru
Thu Apr 13 09:43:59 CEST 2006
- Previous message: [Python-Dev] int vs ssize_t in unicode
- Next message: [Python-Dev] Any reason that any()/all() do not take a predicate argument?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
sorry if this came up before, but I tried searching the archives and found nothing. It would be really nice if new builtin truth functions in 2.5 took a predicate argument(defaults to bool), so one could write, for example:
seq = [1,2,3,4,5] if any(seq, lambda x: x==5): ...
which is clearly more readable than
reduce(seq, lambda x,y: x or y==5, False)
IIRC, something like that is called junctions in Perl 6.
- Previous message: [Python-Dev] int vs ssize_t in unicode
- Next message: [Python-Dev] Any reason that any()/all() do not take a predicate argument?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]