class A:
pass
> A().__class__.__name__
-->'A'
> A.__class__.__name__
--> 'type'
How can I get 'A'
without the parens?
class A:
pass
> A().__class__.__name__
-->'A'
> A.__class__.__name__
--> 'type'
How can I get 'A'
without the parens?
You're getting 'type'
, because the class of a class definition is... type
(in other words: a class definition is a type).
You can just use the __name__
attribute. No need to look for the __class__
, you already have the class:
A.__name__
'A'
Just to make it completely clear:
A().__class__ is A
True