Message194350
Serhiy, Hynek covered the issue with the status quo in the original
proposal.The existing alternative are painful to try and decipher by
comparison with the named function:
filterednext([0, None, False, [], (), 42])
vs
next(filter(None, [0, None, False, [], (), 42]))
filterednext([0, None, False, [], ()], default=42)
vs
next(filter(None, [0, None, False, [], (), 42]), 42)
filterednext([1, 1, 3, 4, 5], key=lambda x: x % 2 == 0)
vs
next(filter(lambda x: x % 2 == 0, [1, 1, 3, 4, 5]))
m = filterednext(regexp.match('abc') for regexp in [re1, re2])
vs
m = next(filter(None, (regexp.match('abc') for regexp in [re1, re2])))
Hynek - the Python 3 filter is an iterator, so it works like the
itertools.ifilter version in Python 2. |
|
Date |
User |
Action |
Args |
2013-08-04 11:38:46 | ncoghlan | set | recipients:
+ ncoghlan, loewis, rhettinger, lukasz.langa, hynek, serhiy.storchaka |
2013-08-04 11:38:45 | ncoghlan | link | issue18652 messages |
2013-08-04 11:38:45 | ncoghlan | create | |
|