2

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'>

0

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.