>>> class A(object): pass
...
>>> A.__dict__
<dictproxy object at 0x173ef30>
>>> A.__dict__.__dict__
Traceback (most recent call last):
File "<string>", line 1, in <fragment>
AttributeError: 'dictproxy' object has no attribute '__dict__'
>>> A.__dict__.copy()
{'__dict__': <attribute '__dict__' of 'A' objects> ... }
>>> A.__dict__['__dict__']
<attribute '__dict__' of 'A' objects> # What is this object?
如果我做A.something = 10
,則進入A.__dict__
。什麼是這個<attribute '__dict__' of 'A' objects>
發現在A.__dict__.__dict__
,它什麼時候包含什麼?什麼是Python類的__dict __.__ dict__屬性?
一個更合適的示例變量可能已經``ive`。至少它會讓這個問題變得更「A .__ dict __ ['ive']`);我會看到自己出來 – Joakim 2015-10-01 15:01:49