作者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/cn.aspx?n=bbs/Python/M.1508433543.A.15B.html