[issue26156] Bad name into power operator syntax
New submission from Chema Cortés: The documentation erroneously changes "primary" for "away" in the power operator syntax: https://docs.python.org/3.6/reference/expressions.html#the-power-operator https://docs.python.org/3.5/reference/expressions.html#the-power-operator ---------- assignee: docs@python components: Documentation messages: 258596 nosy: Chema Cortés, docs@python priority: normal severity: normal status: open title: Bad name into power operator syntax versions: Python 3.5, Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Yury Selivanov added the comment: The docs are correct. See the definition of the "await" expression: https://docs.python.org/3.6/reference/expressions.html#await-expression ---------- nosy: +yselivanov resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Guido Treutwein added the comment: Yurys answer and resolution misses the point. Nobody complained about the await operator. Fact is, that in the _power_ operator (chapter 6.5) as base specification now "await" is given. This is likely to be an inadvertent copy of the previous chapter, makes no sense here and should probably be replaced by "u_expr" or similar. ---------- nosy: +Guido Treutwein _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Robert Jordens added the comment: The original bug report is (apart from spelling) correct. This is a bug and it should be closed. Please reopen. This patch reverts the erroneous change in: changeset: 96185:548d5704fcb3 user: Yury Selivanov <yselivanov@sprymix.com> date: Thu May 21 11:50:30 2015 -0400 summary: Issue 24180: Documentation for PEP 492 changes. ---------- keywords: +patch nosy: +Robert.Jordens Added file: http://bugs.python.org/file42740/issue26156_power.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Robert Jordens added the comment: That should have read "... should _not_ be closed." ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Changes by R. David Murray <rdmurray@bitdance.com>: ---------- resolution: not a bug -> stage: resolved -> commit review status: closed -> open _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Serhiy Storchaka added the comment: The docs looks correct to me. It reflects the fact that the "await" keyword has higher priority than the power operator. "await a ** b" is identical to "(await a) ** b", not "await (a ** b)". ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Yury Selivanov added the comment: Fwiw, I'm -1 on changing this. I think that the current names are correct. ---------- nosy: +Yury.Selivanov _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Serhiy Storchaka added the comment: But to avoid confusion I propose following patch. This may be more correct, since it is strange to name the expression without "await" "await expression". ---------- Added file: http://bugs.python.org/file42741/issue26156_await_power.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Zachary Ware added the comment: I agree that what is currently in the docs is technically correct. The section on the power operator: power ::= await ["**" u_expr] should be read as: power ::= (["await"] primary) ["**" u_expr] just as the definition of 'u_expr' below should be read as: u_expr ::= (await ["**" u_expr]) | "-" u_expr | "+" u_expr | "~" u_expr and 'await' should be read as: await ::= ["await"] (atom | attributeref | subscription | slicing | call) Each definition builds upon previous ones. However, it is confusing. Could a name other than "await" be used, since "await" is easily confused with the keyword await? ---------- nosy: +zach.ware _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Serhiy Storchaka added the comment: May be "w_expr"? ("a_expr" is already used for addition level). ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Yury Selivanov added the comment: Let's call it "await_expr" ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Zachary Ware added the comment: +1 for await_expr ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Serhiy Storchaka added the comment: The confusion is in the definition of await expression with optional "await". Without "await" the expression doesn't suspend the execution of coroutine. And await expression can only be used inside a coroutine function, but the power operator can be used outside. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Robert Jordens added the comment: Ack to the new patch. It is semantically confusing that the await expression also served as the power base without any await. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
R. David Murray added the comment: Sounds like it is a bit more than just confusion: given that power can be used outside a coroutine but await can't, Serhiy's formulation would seem to me to be more semantically correct, even if syntactically it is the same as the current. I think it would regardless be better to replace 'await' with 'await_expr', so +1 on that from me as well. ---------- nosy: +r.david.murray _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Guido Treutwein added the comment: I'm with David here, in that a change would improve ease of comprehension: I still find it strange, that the grammar symbol has the same name as the keyword (or in the proposed version keyword+'expr'), which is never done on more widely used levels. I would have expected something like 'coroutine_suspension', which reflects what it is and not which keyword is required to state it. 2016-05-06 15:04 GMT+02:00 R. David Murray <report@bugs.python.org>:
R. David Murray added the comment:
Sounds like it is a bit more than just confusion: given that power can be used outside a coroutine but await can't, Serhiy's formulation would seem to me to be more semantically correct, even if syntactically it is the same as the current.
I think it would regardless be better to replace 'await' with 'await_expr', so +1 on that from me as well.
---------- nosy: +r.david.murray
_______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Serhiy Storchaka added the comment: I think "await_expr" is good. It is not new that the keyword is a part of the grammar symbol name (yield_expression, comp_for, and_expr, or_test, lambda_expr). ---------- assignee: docs@python -> serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Roundup Robot added the comment: New changeset e876ff4e9e95 by Serhiy Storchaka in branch '3.5': Issue #26156: Make expressions grammar description more semantically correct. https://hg.python.org/cpython/rev/e876ff4e9e95 New changeset 61e3160310ae by Serhiy Storchaka in branch 'default': Issue #26156: Make expressions grammar description more semantically correct. https://hg.python.org/cpython/rev/61e3160310ae ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: ---------- resolution: -> fixed stage: commit review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26156> _______________________________________
participants (8)
-
Chema Cortés -
Guido Treutwein -
R. David Murray -
Robert Jordens -
Roundup Robot -
Serhiy Storchaka -
Yury Selivanov -
Zachary Ware