Equivalent code to the bool() built-in function

candide candide at free.invalid
Mon Apr 18 11:19:26 CEST 2011


Le 18/04/2011 10:33, Raymond Hettinger a écrit :

>> # --------------------------------------
>> def bool_equivalent(x):
>>       return True if x else False
>
> It's faster to write:
>
> def bool_equivalent(x):
>      return not not x
>


faster and ... smarter ;)



More information about the Python-list mailing list