python / python/cpython

Assignment operator: incorrect wording

Aberta
#98,814 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

docs
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Merge médio
1d 9h
PRs com merge (30d)
558

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Revise as seções vinculadas da Language Reference sobre instruções simples e análise léxica, juntamente com a entrada do glossário sobre expressões e a tabela de precedência de operadores. Pesquise na documentação os usos de “assignment operator” e determine quais deveriam dizer “assignment statement”; em seguida, verifique se a terminologia é consistente com o texto de referência ao redor.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
documentation
Tipo de issue
Documentação
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
42/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.