"Late-binding" isn't the issue with closures on a loop
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 文档
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
调研方向
找到指南中解释循环内闭包的段落,并将其措辞与链接的 Lua 示例以及 issue 中的嵌套函数示例进行比较。完成的标准是,解释能够区分延迟绑定和块作用域,并准确描述 Python 的行为。
由索引模型根据 Issue 内容生成。
描述
Lua also has late-binding closures, as can be seen here: https://repl.it/repls/HotpinkEagerQuery (the first one intentionally misused to highlight the difference between block scope and function scope)
It just also has block scope. That's the thing python doesn't have, thus causing the confusion.
Block scope is better emulated with nested functions, such as:
for i in range(5):
def block_scope_emulation(i):
def thing(x):
return x*i
block_scope_emulation(i)
- 主要语言
- Batchfile
- 星标
- 29.8k
- 派生
- 5.9k
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
realpython/python-guide 的其他 Issue
-
Page 404 error 未关闭
难度 1/5 1 小时以内 新手友好度 65/100
realpython/python-guide#1104 · 2 条评论 ·
-
难度 1/5 1-3 小时 新手友好度 62/100
realpython/python-guide#327 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
realpython/python-guide#326 · 5 条评论 ·
-
@alex 未关闭
难度 5/5 一周以上 新手友好度 10/100
realpython/python-guide#1194 ·
-
难度 5/5 一周以上 新手友好度 10/100
realpython/python-guide#1192 ·
查看 realpython/python-guide 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
MystenLabs/sui#28056 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
-
status:untriaged
难度 2/5 1-3 小时 新手友好度 82/100
midnightntwrk/servicedesk#200 ·
-
type/bug
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 72/100
git/git-scm.com#2207 ·