This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Invalid grammar for f_expression
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Kasra Vand, docs@python, eric.smith, serhiy.storchaka
Priority: normal Keywords:

Created on 2019-05-01 10:47 by Kasra Vand, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (5)
msg341186 - (view) Author: Kasra Vand (Kasra Vand) Date: 2019-05-01 10:47
Due to the discussion in following SO question https://stackoverflow.com/questions/55933956/what-does-a-star-asterisk-do-in-f-string/55934472#55933956

and the inconsistency of the source behaviour with the documentation I think using `"*" or_expr` for f_expression is wrong or at least not what it meant to be and very vague. I was wondering if there's any reason for using `"*" or_expr`.
msg341187 - (view) Author: Kasra Vand (Kasra Vand) Date: 2019-05-01 10:54
Due to the discussion in following SO question https://stackoverflow.com/questions/55933956/what-does-a-star-asterisk-do-in-f-string/55934472#55933956

and the inconsistency of the source behaviour with the documentation I think using `"*" or_expr` for f_expression is wrong or at least not what it meant to be and very vague. I was wondering if there's any reason for using `"*" or_expr` instead of let's say just `expr` which I think is what the `or_expr` identifier is intended to be.
msg341190 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-05-01 11:36
I don't think this is a problem. There are plenty of things allowed by Python's grammar that are converted to errors in subsequent passes. For example:

>>> *[1]
  File "<stdin>", line 1
SyntaxError: can't use starred expression here
>>> *[1],*[2]
(1, 2)
msg341249 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-05-02 05:55
Concur with Eric. The formal definition of the Python grammar is wider than valid Python, because we do not want to make it too complex. Invalid constructions are filtered out later.
msg341254 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-05-02 08:08
Thanks, Serhiy.

I suppose that we could add a note to the documentation, but I'm not sure it would be worth the confusion it would create. It's best to think of this is "it's just an expression,  like everywhere else in Python". If I ever decide I like PEP 536, maybe then things will become clearer (although possibly not: the same issue will still exist, but I think it will become more obvious that expressions are treated just like they are elsewhere).

So I'm going to close this.
History
Date User Action Args
2022-04-11 14:59:14adminsetgithub: 80946
2019-05-02 08:08:36eric.smithsetstatus: open -> closed
resolution: not a bug
messages: + msg341254

stage: resolved
2019-05-02 05:55:36serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg341249
2019-05-01 11:36:08eric.smithsetmessages: + msg341190
2019-05-01 11:30:01xtreaksetnosy: + eric.smith
2019-05-01 10:54:26Kasra Vandsetmessages: + msg341187
2019-05-01 10:47:02Kasra Vandcreate