realpython / realpython/python-guide
"Late-binding" isn't the issue with closures on a loop
オープン
まだ誰も着手していません。
- 主要言語
- Batchfile
- スター
- 29.8k
- フォーク
- 5.9k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ループ内のクロージャを説明しているガイドの箇所を見つけ、その文面をリンクされた Lua の例および issue 内の入れ子関数の例と比較してください。完了条件は、説明が遅延バインディングとブロックスコープを区別し、Python の動作を正確に記述していることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua, python
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100