Message388555
> This seams really inconsistent with the rest of the ast, where identifiers are always wrapped in a ast.Name object. The only other exception to this is ast.Attribute.
import ... as <identifier>
from ... import ... as <identifier>
try:
...
except ... as <identifier>:
...
global <identifier>
nonlocal <identifier>
x(<identifier>=...)
All <identifier>s above are represented as strings. If <identifier> is guaranteed to be a single name, then it makes sense to just use an identifier instead of wrapping it with Name(). The reason that other stuff like "with ... as <expr>" uses <expr> instead of <identifier> is that you can use extended assignment targets (such as unpacking a tuple) over there.
This rule applies to all other stuff, except for NamedExprs. Which I believe it is because the restriction might lift in the future, but now they are limited to only keep Name()s.
I don't personally know why Brandt choosed to use identifier, though I'm a +1 on the current approach. |
|
Date |
User |
Action |
Args |
2021-03-12 21:30:32 | BTaskaya | set | recipients:
+ BTaskaya, gvanrossum, rhettinger, willingc, Daniel Moisset, lys.nikolaou, pablogsal, xtreak, brandtbucher, kj, laurenjl, freundTech |
2021-03-12 21:30:32 | BTaskaya | set | messageid: <1615584632.85.0.852512197446.issue42128@roundup.psfhosted.org> |
2021-03-12 21:30:32 | BTaskaya | link | issue42128 messages |
2021-03-12 21:30:32 | BTaskaya | create | |
|