Nick Coghlan added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18652>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com