Re: [問題] 英文實在看不懂,能不能請各位幫忙解釋?
※ 引述《ResolaQQ (ResolaQQ)》之銘言:
: constants
: all module globals are considered constants. Their binding must not be
: changed at run-time. Moreover, global (i.e. prebuilt) lists and
: dictionaries are supposed to be immutable: modifying e.g. a global list
: will give inconsistent results. However, global instances don't have this
: restriction, so if you need mutable global state, store it in the
: attributes of some prebuilt singleton instance.
你下面的例子和這段文字毫不衝突, 反而是它推薦的做法
我就直接翻成中文, 你自己感受一下, 應該不需要太多解釋
所有 module 中的全域變數應被視為常數。它們的鍵結不應於執行期被改變。
除此之外, 全域(亦即預先建立的)list 與 dictionary 實例應不可修改:
舉例而言, 修改一個全域 list 會產生不一致的結果。然而, 全域物件實例並
無此限制, 所以若你需要可被修改的全域狀態, 應將其存至某個預先建立
singleton 實例的 attribute。
--
→
08/10 00:59,
08/10 00:59
→
08/10 02:16,
08/10 02:16
→
08/10 20:18,
08/10 20:18
→
08/10 20:19,
08/10 20:19
→
08/10 20:21,
08/10 20:21
→
08/11 20:23,
08/11 20:23
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 101.13.226.119
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1454511104.A.48E.html
推
02/03 23:27, , 1F
02/03 23:27, 1F
推
02/04 00:15, , 2F
02/04 00:15, 2F
→
02/04 00:16, , 3F
02/04 00:16, 3F
→
02/04 00:44, , 4F
02/04 00:44, 4F
→
02/04 00:46, , 5F
02/04 00:46, 5F
推
02/04 01:10, , 6F
02/04 01:10, 6F
→
02/04 01:12, , 7F
02/04 01:12, 7F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 3 篇):