"Late-binding" isn't the issue with closures on a loop
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Documentation
- Clarity
- Needs clarification
- Activity status
- Stale
- Domain
- documentation
Research direction
Locate the guide passage that explains closures in a loop and compare its wording with the linked Lua example and the nested-function example in the issue. Done means the explanation distinguishes late binding from block scope and accurately describes the Python behavior.
Written by the indexing model from the issue text.
Description
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)
- Dominant language
- Batchfile
- Stars
- 29.8k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from realpython/python-guide
-
Page 404 error Open
Difficulty 1/5 Under an hour Newbie friendliness 65/100
realpython/python-guide#1104 · 2 comments ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 62/100
realpython/python-guide#327 ·
-
PyZMQ improvements Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
realpython/python-guide#326 · 5 comments ·
-
@alex Open
Difficulty 5/5 Over a week Newbie friendliness 10/100
realpython/python-guide#1194 ·
-
Development Team SAP Open
Difficulty 5/5 Over a week Newbie friendliness 10/100
realpython/python-guide#1192 ·
All issues in realpython/python-guide
Similar issues
-
area:dictation documentation P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
uttrflow/uttrflow-swift#1180 ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
githubnext/gh-aw-workshop#3692 ·
-
agent/guide documentation hive/hosted-available-lke648397-260827-5n31
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
falcosecurity/falco-website#1601 ·
-
specification
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
WICG/webmonetization#729 ·