Do you agree with this use of the term "operator"?
Because there is no such "comma operator" in Python as
explained by the official FAQ
Quotes from The Python Language Reference, Release 3.10.8:
- Note that tuples are not formed by the parentheses, but rather by use of the comma operator (p. 66)
- Note: If the object is a class instance and the attribute reference occurs on both sides of the assignment operator (p. 86)
- The second half of the list, the augmented assignment operators, serve lexically as delimiters, but also perform an operation (p. 15)
Do you agree with this use of the term "operator"?It's a bit fuzzy, I guess. Comma, =, +=, *= etc. are in section 2.6 "Delimiters" and not in section 2.5 "Operators" of The Python Language Reference, which would seem to imply that those are not operators. But
Because there is no such "comma operator" in Python as explained by the official FAQ: https://docs.python.org/3/faq/programming.html#what-s-up-with-the-comma-operator-s-precedenceThat does seem to contradict the text in the language reference.
And, =, += and the like are not operators since (a=b), (a+=b), etc have no value. There is no assignment operator instead there exists an assignment statement. The only assignment operator I can figure out is the walrus operator.I think that's a good point too. The language reference calls those
No. If the docs say in one place a comma is not an operator, they shouldn’t call it an operator in another place.
I’ve submitted a pull request https://github.com/python/cpython/pull/98736 -- we’ll have to see what The Powers That Be think.
Le mercredi 26 octobre 2022 Ă 22:12:59 UTC+2, Weatherby,Gerard a ecrit :
No. If the docs say in one place a comma is not an operator, they shouldn’t call it an operator in another place.
I’ve submitted a pull request https://github.com/python/cpython/pull/98736 -- we’ll have to see what The Powers That Be think.
Thanks for the (merged) pull request about the "comma operator"!assignement statement" or "assignement symbol".
I return to the last two quotes in the Reference Document regarding these so-called "assignment operators".
The entry in the glossary explains that the comma symbol is not an operator. Well, I just realized that this same entry also explains that the = symbol is not an operator, as you can see by reading the end of their response:
The same is true of the various assignment operators (=, += etc). They are not truly operators but syntactic delimiters in assignment statements.
(glossary entry link: https://docs.python.org/3/faq/programming.html#what-s-up-with-the-comma-operator-s-precedence)
Talking about an assignment operator in Python is even more confusing because, since Python 3.8, there is a real assignment operator, namely the walrus operator. As explained above, the correct expression would be "assignement delimiter" or "
Wording is hard. Just ask the SQL standard whether NULL is a value.
Le lundi 31 octobre 2022 Ă 22:18:57 UTC+1, Chris Angelico a ecrit :
Wording is hard. Just ask the SQL standard whether NULL is a value.
Indeed, but I think our problem here is simpler ;)
One could for example omit the incorrect term "operator" while remaining unambiguous. This would give:
Yep. The word "operator" is incorrect when referring to Python's comma
(in contrast to, say, C, where the comma actually *is* an operator);
and from my understanding, the docs have already been updated to fix
this.
ChrisA
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 70:53:07 |
Calls: | 6,712 |
Files: | 12,244 |
Messages: | 5,356,851 |