Writing a string.ishex function

D'Arcy J.M. Cain darcy at druid.net
Thu Jan 14 12:44:27 EST 2010


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)


-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



More information about the Python-list mailing list