作者zerof (貓橘毛發呆雕像)
看板Python
標題Re: [問題] 怎麼用 Python 寫出 switch 的功能?
時間Fri Oct 20 01:18:58 2017
class-based
https://repl.it/JZn4/12
但還是很醜........
如果沒猜錯的話,外層應該會在 init() < 0 的時候再 release_process3() 。
這樣的行為跟 switch-case 的 fall-through 其實沒啥關係...
(btw, golang 的 switch 是 fall-through by default)
比較有關的大概是 RAII (
https://goo.gl/jZHYyw ),在 Python 基本上就是用
context manager 來實作。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.77.72.241
※ 文章網址: https://webptt.com/m.aspx?n=bbs/Python/M.1508433543.A.15B.html