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
Written by KOIZUMI teruaki
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Related Tags
#python
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#