realpython / realpython/python-guide
Code Style - not really good list manipulation example - needs explanation
オープン
まだ誰も着手していません。
- 主要言語
- Batchfile
- スター
- 29.8k
- フォーク
- 5.9k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
In the Code Style chapter examples - Short Ways to Manipulate Lists there is an example "Add three to all list members."
"bad"
for i in range(len(a)):
a[i] += 3
"good"
a = [i + 3 for i in a]
Unfortunately the "bad" and "good" examples do a different things:
- "bad" modifies the original list in place
- "good" creates a new modified list and does not change the original object - not exactly "Add three to all list members."
Although the "good" code looks cleaner the result could be unwanted for example in case of huge lists or required side-effect of modifying the original list. The code at least needs an explanation.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
writing/style.html の Code Style 章を開き、“Short Ways to Manipulate Lists” セクションを読んでください。2 つのリスト例を比較し、in-place で変更する場合と新しいリストを作成する場合の挙動の違いが明確になるよう、周囲の説明を更新してください。各例が元のリストを変更するのはいつなのかを読者が理解できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100