More elegant to get a name: o.__class__.__name__

Carl Banks pavlovevidence at
Thu Nov 30 15:25:40 CET 2006

alf wrote:
> Hi,
> is there a more elegant way to get o.__class__.__name__. For instance I
> would imagine name(o).

def name_of_type(o):
    return o.__class__.__name__


Carl Banks

P.S. name(o) suggests it's the name of the object, not the type
P.P.S. you could use type(o).__name__ but it doesn't work for old-style

More information about the Python-list mailing list