Last Updated: February 25, 2016
·
1.653K
· terukizm

isHex in Python at lazy style

normaly:

def ishex(val):
try:
int(val, 16)
return True
except ValueError, e:
return False

tiresome:

a = 'FF00FF'
import string
set(a).issubset(set(string.hexdigits))
-> True