看板 [ Python ]
討論串[問題] 隱藏類別中的屬性
共 2 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓2(2推 0噓 13→)留言15則,0人參與, 最新作者icetofux時間7年前 (2016/10/14 10:38), 編輯資訊
1
0
0
內容預覽:
我在python 3.5.1的環境下做了一個簡單的測試,想要做到類似其他程式語言中. "private"的功能:. test.py. 1 class StateMachine:. 2 def __init__(self):. 3 self.__state = "IDLE". 4. 5 def sta
(還有413個字)

推噓2(2推 0噓 0→)留言2則,0人參與, 最新作者uranusjr (←這人是超級笨蛋)時間7年前 (2016/10/14 11:40), 7年前編輯資訊
0
0
1
內容預覽:
Python 的 self.__member 並不會造成這個成員被隱藏, 而是會觸發 name mangling:https://en.wikipedia.org/wiki/Name_mangling#Python. >>> class Foo:. ... def __init__(self):.
(還有1063個字)
首頁
上一頁
1
下一頁
尾頁