Ruby 中以下代码的 Python 等价物是什么?
def loop
cont=nil
for i in 1..4
puts i
callcc {|continuation| cont=continuation} if i==2
end
return cont
end
> c=loop
1
2
3
4
> c.call
3
4
引用:Secrets of lightweight development success, Part 9: Continuations-based frameworks
最佳答案
您引用的文章包含指向 Continuations Made Simple And Illustrated 的链接在引用资料部分,讨论 Python 语言中的延续。
关于Python 等同于 Ruby 的延续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/312794/