Issue 36765: Invalid grammar for f_expression (original) (raw)
Issue36765
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) * ![]() |
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 "", line 1 SyntaxError: can't use starred expression here >>> *[1],*[2] (1, 2) | ||
msg341249 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
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) * ![]() |
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:14 | admin | set | github: 80946 |
2019-05-02 08:08:36 | eric.smith | set | status: open -> closedresolution: not a bugmessages: + stage: resolved |
2019-05-02 05:55:36 | serhiy.storchaka | set | nosy: + serhiy.storchakamessages: + |
2019-05-01 11:36:08 | eric.smith | set | messages: + |
2019-05-01 11:30:01 | xtreak | set | nosy: + eric.smith |
2019-05-01 10:54:26 | Kasra Vand | set | messages: + |
2019-05-01 10:47:02 | Kasra Vand | create |