Writing a string.ishex function

MRAB python at mrabarnett.plus.com
Thu Jan 14 14:49:10 EST 2010


Duncan Booth wrote:
> MRAB <python at mrabarnett.plus.com> wrote:
> 
>> I raise you one character:
>>
>> ishex2 = lambda s: not(set(s)-set(string.hexdigits))     # Yours
>> ishex3 = lambda s: not set(s)-set(string.hexdigits)      # Mine
>>
>> I could actually go three better:
>>
>> ishex3=lambda s:not set(s)-set(string.hexdigits)
> 
> But none of those pass your own "ishex('') should return False" test.

Neither do the others!



More information about the Python-list mailing list