0

I've been playing around with the built-in types in Python 3 for a bit and I've noticed that all classes are instances of the more general class type, for example typing int.__class__.__name__ results in type. The same goes for any user-generated class. However, type itself is of type type - typing type.__class__.__name__ results in type.

However, this does not make much sense to me. How can a class be an instance of itself? Why is type not an instance of object, the most basic class of all? Or is this some low-level magic that is being hidden from the end user?

Smiley1000
  • 95
  • 2
  • 10
  • Have you read e.g. https://stackoverflow.com/questions/55775218/python-3-why-is-object-an-instance-of-type-and-type-an-instance-of-objec? – jonrsharpe Apr 30 '20 at 19:08
  • I have not seen that question yet. I suppose I can close this question as duplicate now? – Smiley1000 Apr 30 '20 at 19:11
  • Yes, that post answers my question. It seems I don't have enough reputation (250 supposedly) to mark my own question as duplicate. I'd enjoy if someone else would do that instead. – Smiley1000 Apr 30 '20 at 19:16

0 Answers0