ishexdigit()

Jeff Epler jepler at unpythonic.net
Wed Dec 31 17:50:48 EST 2003


On Wed, Dec 31, 2003 at 01:16:22PM -0800, Raymond Hettinger wrote:
> The category of Fastest Code is much less vague but tends towards
> using fancy tricks:
> 
>     def ishexstring(s):
>         try:
>             int(s, 16)
>         except ValueError:
>             return False
>         return True

>>> ishexstring("0xff")
True

... but probably it doesn't fit the OP's definition

Jeff





More information about the Python-list mailing list