python / python/cpython

Assignment operator: incorrect wording

Open
#98,814 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

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".

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the linked Language Reference sections on simple statements and lexical analysis, along with the expression glossary entry and operator-precedence table. Search the documentation for uses of “assignment operator” and determine which should say “assignment statement,” then verify the terminology is consistent with the surrounding reference text.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.