realpython / realpython/python-guide

"Late-binding" isn't the issue with closures on a loop

オープン
#1,030 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
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)

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

ループ内のクロージャを説明しているガイドの箇所を見つけ、その文面をリンクされた Lua の例および issue 内の入れ子関数の例と比較してください。完了条件は、説明が遅延バインディングとブロックスコープを区別し、Python の動作を正確に記述していることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
lua, python
領域
documentation
issue の種類
ドキュメント
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。