Most sources online call = (and +=, -=, etc...) an assignment operator (for python). This makes sense in most languages, however, not in python. An operator takes one or more operands, returns a value, and forms an expression. However, in python, assignment is not an expression, and assignment does not yield a value. Therefore, = cannot be an operator.
So what exactly is it? In a statement like x = 0, x is an identifier, 0 is a numeric literal, but I don't know what to call "=".
The assignment symbol
=behaves like a statement, not as an operator. It supports chaining as part of the syntax but cannot be used as an operation (e.g.a = b = 0but notif a = b:).It is similar to the
inpart of afor ... in ...:statement. Thatinis part of the statement syntax, it is not the actualinoperator.