Writing a string.ishex function

Terry Reedy tjreedy at udel.edu
Thu Jan 14 23:14:41 CET 2010

On 1/14/2010 12:44 PM, D'Arcy J.M. Cain wrote:
> On Thu, 14 Jan 2010 09:07:47 -0800
> Chris Rebert<clp2 at rebertia.com>  wrote:
>> Even more succinctly:
>> def ishex(s):
>>      return all(c in string.hexdigits for c in s)
> I'll see your two-liner and raise you.  :-)
> ishex = lambda s: all(c in string.hexdigits for c in s)

This is inferior because the resulting function object has generic name 
attribute '<lambda>' instead of the specific name 'ishax'.

Please do not push such inferior code on new programmers.

Terry Jan Reedy

More information about the Python-list mailing list