0
class A:
    pass

> A().__class__.__name__ 
-->'A'
> A.__class__.__name__
--> 'type'

How can I get 'A' without the parens?

Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
John Difool
  • 5,572
  • 5
  • 45
  • 80

1 Answers1

2

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

Błażej Michalik
  • 4,474
  • 40
  • 55