NEWBIE: What's the instance name?

David M. Wilson at
Tue Dec 30 14:38:41 CET 2003

bokr at (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. :)


More information about the Python-list mailing list