1

I was checking type of every thing in python. But I could not understand why the type of a class is <class 'type'>

class Hello:
    pass


c = Hello
print('type check one: ', type(c))
print('type check two: ', type(Hello))

output:- type check one: <class 'type'> type check two: <class 'type'>

Rasheed kotoor
  • 257
  • 2
  • 14

1 Answers1

3

type is a metaclass in Python

A metaclass is just a class of a class, as explained here.

Because you did not specify what type of object c was, and instead said it is just a Hello class, Hello inherits from type, thus making it of a type class.

artemis
  • 6,857
  • 11
  • 46
  • 99