[Python-ideas] Break the dominance of boolean values in boolean context
Carl Matthew Johnson
cmjohnson.mailinglist at gmail.com
Thu Sep 15 06:01:20 CEST 2011
On Sep 14, 2011, at 5:41 PM, Greg Ewing wrote:
> On 15/09/11 11:25, MRAB wrote:
>
>> Could it also have something like a 'key' argument, by default
>> __bool__?
>
> Or more generally, a function.
>
> Although that's not strictly necessary. If there were a first()
> function that simply returned the first item from an iterator,
> whether true or not, one could write
>
> first(itertools.ifilter(func, something))
>
Time machine:
next(filter(func, something)) #in Python 3, filter is ifilter!
:-D
More information about the Python-ideas
mailing list