[Python-ideas] Break the dominance of boolean values in boolean context

Steven D'Aprano steve at pearwood.info
Fri Sep 16 05:57:55 CEST 2011


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))


Surely the way to return the first item from an iterator, whether true 
or not, is next(iterator)?



-- 
Steven




More information about the Python-ideas mailing list