Code Style - not really good list manipulation example - needs explanation

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

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

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
45/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
documentation

調査の方向性

writing/style.html の Code Style 章を開き、“Short Ways to Manipulate Lists” セクションを読んでください。2 つのリスト例を比較し、in-place で変更する場合と新しいリストを作成する場合の挙動の違いが明確になるよう、周囲の説明を更新してください。各例が元のリストを変更するのはいつなのかを読者が理解できれば完了です。

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

説明

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.

主要言語
Batchfile
スター
29.8k
フォーク
5.9k
PR マージ指標
30日以内にマージされた PR はありません

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

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

はじめの一歩

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

realpython/python-guide のほかの issue

realpython/python-guide の issue をすべて見る

似ている issue

Documentation の issue をもっと見る

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

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