NEWBIE: What's the instance name?
David M. Wilson
dw-google.com at botanicus.net
Tue Dec 30 08:38:41 EST 2003
bokr at oz.net (Bengt Richter) wrote...
> But that will accept '0x55' which I doubt the OP will like ;-)
I should really learn to try my own code out on some inputs before
posting. :)
Another alternative for doing this test is a regular expression.. one
of the few times I would actually use them:
def is_hex(s):
return re.match('^[a-fA-F0-9]{4}$', s) is not None
Using a compiled regex would be faster, but since I can't currently
figure out a way of storing such an 'implementation internal' object
without using a global, callable instance, or default argument, I'm
not going do it that way. :)
David.
More information about the Python-list
mailing list