>>> class C:
... pass
...
>>> C.__dict__
mappingproxy({'__doc__': None,
'__weakref__': <attribute '__weakref__' of 'C' objects>,
'__dict__': <attribute '__dict__' of 'C' objects>,
'__module__': '__main__'})
在<attribute 'xxx' of 'C' objects>
,'C'對象的`<attribute'xxx'是什麼意思在`C .__ dict__`的輸出中?
- 做的
C
'C' objects
平均情況? - 確實
<attribute 'xxx' of 'C' objects>
的意思是xxx
是C
實例的一個屬性?但它被列爲C.__dict__
作爲C
的屬性。
爲什麼不<attribute 'xxx' of 'C' objects>
提到C
一些屬性(例如__doc__
和__module__
),而另一些?
回覆: 「注:<attribute ..>
基本上是這些描述符的再版」
爲什麼沒有在下面的示例所示<attribute ..>
?
>>> class md:
... def __get__(self, obj, owner):
... return 3
...
>>> class CC:
... d=md()
...
>>> CC.__dict__
mappingproxy({'d': <__main__.md object at 0x7f7387f8c978>, ...})
,如果你認爲'C .__類的輸出這個問題就更加有趣__.__ dict__' – Guillaume
我注意到@Tim那你經常添加致歡迎詞句話你的問題。雖然在與某人面對面交談時這當然被認爲是禮貌的,但它只會給Stack Overflow上的帖子增加噪音。請參閱[_why是老鄉用戶刪除感謝你從我的問題是?_](https://meta.stackoverflow.com/questions/328379/why-are-fellow-users-removing-thank-yous-from-my-問題)瞭解更多詳情。 –