testing for class of instance

Greg Ball greg.ball at earthling.net
Sun May 13 16:57:54 CEST 2001

Stephen Hansen <news at mynospam.org> wrote:

> def printname(object):
>     try:
>         print 'My name is ', object[name]
>     except TypeError, AttributeError:
>         print 'You didn't send me a dictionary-like object!'

You mean 

      except (TypeError,AttributeError):

As written, you will catch only TypeError, and when
you do, you'll assign the exception to local variable

See  http://www.amk.ca/python/writing/warts.html

--Greg Ball

More information about the Python-list mailing list