0
class A:
    pass

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

How can I get 'A' without the parens?

Aran-Fey
  • 35,525
  • 9
  • 94
  • 135
John Difool
  • 5,204
  • 4
  • 40
  • 70

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
  • 3,727
  • 34
  • 47