leo.zhang
leo.zhang

Reputation: 125

Is assignment an operator in Python?

I checked the operator precedence in Python 3, and found that there is no assignment (=).

I want to know if assignment is an operator or not. If not, why are there so many "assignment operator" hits when Googled? What is the precedence relation with other real operators (bool operator, comparison operator, etc.)?

Upvotes: 3

Views: 327

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599490

No. An assignment is always a statement in Python.

That's why things like assignment within if statements, which is acceptable in some other languages, is forbidden in Python.

Upvotes: 6

Related Questions