Document usage of comprehensions with multiple if clauses
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Documentation
As noted in the documentation for list comprehensions (and also in the reference docs on expressions, but not in the glossary which refers to an "if clause" in the singular), list/set/dict comprehensions can accept zero or more if clauses like so:
[i for i in range(10) if i % 2 if i % 3]
Looking at the bytecode generated with python -m dis, this appears to be strictly equivalent to:
[i for i in range(10) if i % 2 and i % 3]
(The last if was replaced by and)
It would be nice if this was documented, and ideally with examples.
I'm also personally curious why that feature exists so if someone could point me to an explanation I'd appreciate it. I didn't find anything in what I believe is the original PEP for list comprehensions (PEP 202).
Linked PRs
- gh-138217
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まずリンクされている PR gh-138217 を確認し、次に issue で指定されている list comprehension チュートリアル、式リファレンス、用語集の各セクションを比較します。完了条件は、ドキュメントで comprehensions が複数の if 節をサポートすることを説明し、代表的な例を含めることです。既存のリファレンスが根拠を裏付けている場合は、その理由も追加します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100