(似乎没法分开显示不同的文件。。。)
看了这篇文章(http://coolshell.cn/articles/10739.html),有一个 Lua 写的 counter,觉得有趣:
https://gist.github.com/wenLiangcan/10135400#file-counter-lua
于是学着用 Python 写了一下,可是出错了:
https://gist.github.com/wenLiangcan/10135400#file-er_counter-py
搜索后看到这篇文章(http://jjinux.blogspot.com/2006/10/python-modifying-counter-in-closure.html),说把记录计数的变量换做列表就可以了:
https://gist.github.com/wenLiangcan/10135400#file-counter-py
请问这是为什么呢?上面文章提到的“to box variables within a closure”又是什么意思?
谢谢
看了这篇文章(http://coolshell.cn/articles/10739.html),有一个 Lua 写的 counter,觉得有趣:
https://gist.github.com/wenLiangcan/10135400#file-counter-lua
于是学着用 Python 写了一下,可是出错了:
https://gist.github.com/wenLiangcan/10135400#file-er_counter-py
搜索后看到这篇文章(http://jjinux.blogspot.com/2006/10/python-modifying-counter-in-closure.html),说把记录计数的变量换做列表就可以了:
https://gist.github.com/wenLiangcan/10135400#file-counter-py
请问这是为什么呢?上面文章提到的“to box variables within a closure”又是什么意思?
谢谢
