NEWBIE: What's the instance name?

engsolnom at ipns.com engsolnom at ipns.com
Sun Dec 28 21:15:49 EST 2003


Hi,
I've been using constructs(?) like the below.

def display(instance, start = None, end = None):

    if instance.__class__.__name__ == 'UPCA':
        do some UPCA stuff
    if instance.__class__.__name__ == 'UPCE':
        do some UPCE stuff

launched by:

lx = UPCA(sx), where sx is a string
then:
display(lx)

This all works well.

What I'd like to do is display is the instance name. Is it hiding
somewhere?

Also, if I have a string 4 chars long, representing two bytes of hex,
how can I *validate* the string as a *legal* hex string?

isdigit works until string = '001A', for example
isalnum works, but then allows 'foob'

Is there a 'ishexdigit'? I could parse the string, but that seems
"un-Pythonish"

Thanks in advane....Norm




More information about the Python-list mailing list