Name of type of object

Randall Smith randall at tnr.cc
Wed Feb 9 02:06:42 EST 2005


Jive Dadson wrote:
> The traceback routine prints out stuff like,
> 
> 	NameError: global name 'foo' is not defined
> 
> NameError is a standard exception type.
> 
> What if I want to print out something like that?
> I've determined that "global name 'foo' is not defined" comes 
> from the __str__ member of the exception object.
> Where does it find the string "NameError"?  In general, if I have 
> an object, is there a way to obtain the name of the type of the object?
> 
> Thankee.

type(object) ?

Randall



More information about the Python-list mailing list