How to find the classname of an object? (was Python Documentation)
Christopher J. Bottaro
cjbottaro at alumni.cs.utexas.edu
Fri May 13 10:35:15 EDT 2005
Bengt Richter wrote:
> >>> type(obj)
> <class '__main__.A'>
> >>> type(obj).mro()
> [<class '__main__.A'>, <class '__main__.B1'>, <class '__main__.B2'>,
> [<class '__main__.C'>, <type 'object'>]
> >>> tuple(x.__name__ for x in type(obj).mro())
> ('A', 'B1', 'B2', 'C', 'object')
Wow awesome, thats exactly what I was looking for. I hate to bring up the
documentation thing again...but.....where the hell is this in the
documentation? I looked under built-in function at type(), but it doesn't
give any info or links on the "type object".
Thanks.
--C
More information about the Python-list
mailing list