How to find the classname of an object? (was Python Documentation)
Steven Bethard
steven.bethard at gmail.com
Fri May 13 13:32:15 EDT 2005
Christopher J. Bottaro wrote:
> 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?
py> help(type)
Help on class type in module __builtin__:
class type(object)
| type(object) -> the object's type
| type(name, bases, dict) -> a new type
...
| mro(...)
| mro() -> list
| return a type's method resolution order
...
Or even:
py> help(type.mro)
Help on method_descriptor:
mro(...)
mro() -> list
return a type's method resolution order
But yeah, I couldn't find it in the docs either. Please file a
documentation feature request:
http://sourceforge.net/tracker/?group_id=5470&atid=355470
STeVe
More information about the Python-list
mailing list