0

See Is assignment an operator in Python? The answer states:

An assignment is always a statement in Python.

Now, see this link of Assignment Statements. In that, see the Note section (emphasis mine):

Note: If the object is a class instance and the attribute reference occurs on both sides of the assignment operator, the right-hand side expression, a.x can access either an instance attribute or (if no instance attribute exists) a class attribute.

Here the term "assignment operator" is used. Now, the list of operators in the official documentation of Python does not contain an assignment operator, but = is contained in the Delimiters section.

Is assignment an operator, a statement, or a delimiter?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • 1
    Didn't you ask this already? Also, realistically, does it matter? `=` is a delimiter *in* a statement, so your options aren't actually mutually exclusive. – jonrsharpe May 29 '20 at 14:31
  • 6
    Assignments involving the `=` character can only occur in statements. So it's an assignment statement. A statement of course consists of multiple parts. So how do you call the `=` character within the assignment statement? Syntactically *delimiter* is correct, but colloquially "operator" is more understood. Probably the author of that note slipped into a colloquialism there. – deceze May 29 '20 at 14:33
  • 1
    We should call `:=` *the* assignment operator. Or walrus. – timgeb May 29 '20 at 14:37
  • 2
    @timgeb Now you're just asking for mass confusion. :P – deceze May 29 '20 at 14:38
  • Do people even use the walrus operator? – bug_spray May 29 '20 at 14:51
  • @bug_spray I don't think it will be available until Python 3.9. Hard to use something that doesn't exist yet. – Mark Ransom May 29 '20 at 15:34
  • @Mark You think wrong. https://docs.python.org/3/whatsnew/3.8.html#assignment-expressions – deceze May 29 '20 at 16:06
  • @deceze thanks for the correction. So it's been available for 7 months. – Mark Ransom May 29 '20 at 16:10

0 Answers0