python / python/cpython

Assignment operator: incorrect wording

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

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

docs
主要言語
Python
スター
77.2k
フォーク
36k
平均マージ
1日 9時間
マージ済み PR(30日)
558

説明

Two quotes from The Python 3.11.0 Language Reference (emphasize is mine):

  • Note: If the object is a class instance and the attribute reference occurs on both sides of the assignment operator
  • Delimiters: The second half of the list, the augmented assignment operators, serve lexically as delimiters, but also perform an operation

As explained at the expression entry term in the glossary, an operator is a syntatical element involved in an expression. An expression has a value. The piece of syntax (a = expr) is not an expression because it cannot be evaluated. And as explained at the same entry, assignment are also statement, not expression.

In the same way there is no del/return operator, it is not correct to invoke an assignment operator, the correct wording being "assignment statement" as used in many places in The Python Language Reference Manual. The only "assignment operator" we can figure out is the walrus operator because (a := expr) has a value.

For consistency, we can observe that assignment symbols (=, +=, etc), contrary to the walrus symbol, are not listed in:

  • the set of tokens considered as operators
  • the operator precedence table.

Thomas Wouters explains in a SO comment :

Assignment is actually not an expression in Python, and = not an operator in the normal sense; operator precedence doesn't apply.

Related reference of interest: = is not an operator

EDIT:

...doesn't exist, since '=' is not an operator in Python (just like it isn't, say, in VB). But, OK, you mean "assignment".

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

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

はじめの一歩

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

調査の方向性

単純文と字句解析に関するリンク先のLanguage Referenceのセクション、および式の用語集エントリと演算子の優先順位表を確認してください。ドキュメント内で「assignment operator」の使用箇所を検索し、そのうちどれが「assignment statement」とすべきかを判断してから、周囲のリファレンステキストと用語が一貫していることを確認してください。

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

評価

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

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

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