Recently i accidentally saw a strange behaviour of Python:
The object
class, which is inherited implicitly, doesn’t have a __dict__
. But every inherited class, even if you don’t add anything to it (e.g. class A: pass
), a __dict__
member is automaticly created. My only guess is that it’s created by type() metaclass, but i can’t find its realization. I have searched in the PyPy and CPython githubs and in Python’s docs.
I found out that if you create class A: pass
, dir(A)
shows that even A has a __dict__
member. Well, now my question is, is it possible to see the type() realization anywhere?
karlstedt020 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
0