If I run the following code in a Python interpreter:
>>> object.__dict__ is object.__dict__
False
Why is the result False?
object.__dict__, unlike other __dict__s, returns a mappingproxy object (a dict_proxy in Python 2). These are created on the fly when __dict__ is requested. So as a result, you get a new proxy every time you access object.__dict__. They all proxy the same underlying object, but the proxy is a fresh one all the time. That’s why you can’t get two identical ones.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With