Idea for key parameter in all() builting, would it be feasible?

Chris Angelico rosuav at gmail.com
Thu Jun 20 11:48:12 EDT 2013


On Fri, Jun 21, 2013 at 12:49 AM, Russel Walker <russ.pobox at gmail.com> wrote:
> On Thursday, June 20, 2013 12:45:27 PM UTC+2, Antoon Pardon wrote:
>> Op 19-06-13 18:14, russ.pobox at gmail.com schreef:
>>
>> >
>>
>> >>>> all(map(lambda x: bool(x), xrange(10**9)))
>>
>> Since you already have your answer, I just like to get your attention
>> to the fact the the lambda is superfluous here. Your expression
>> above is equivallent to
>>
>>   all(map(bool, xrange(10**9)))
>
> That's true, I didn't notice that. Although it was a trivial example I was setting up from the actual code and couldn't think of what to shove inside lambda so bool got the short straw.

Yeah, I've been guilty of that fairly often - making a trivial example
that can be trivialized even more. Sometimes all you need to do is
acknowledge it with a comment and move on, other times the additional
trivialization is a clue to the actual problem :)

In this particular case, all() will boolify anyway, so you don't even
need map. But that would completely destroy your example:

all(xrange(10**9)) # Doesn't help with figuring out the original issue!

ChrisA



More information about the Python-list mailing list