I implemented both versions with f and $ as prefixes for { ![]()
f: Comparing main...c9004e5977a05d5ac644e1741adc446af96d0f29 · python/cpython · GitHub$: https://github.com/python/cpython/pull/152820/commits/657fff2f18a84601a180f1be74876c537fc9b7eb
Now, we would have to decide which one is better. There are several concerns for each of them:
f- Looks like fstring:
f{0}andf'{0}', but does a completely different thing: Frozen vs Format - In fstring you can use both
Fandf, it would be strange to allow the same forf{. So, it would be incosinstent - It is rather hard to read when these things are nested:
f{f'{user}', f'{task}'} - It does not scale for other possible similar syntax (which is not a part of the proposal, but just a possibiliy for the future). Because
f()andf[]are already valid as a syntax
Now, the second option:
$- It is a new unfamiliar thing, that people might associate with PHP or BASH
- It one of the last unused symbols in the syntax
Why not some other options?
- No identifiers apply because of the scalability concerns
- No suffixes apply, because it is hard to read
- No chars that are used in operators apply, because they create ambiguity when parsing
- No existing valid syntax apply, we can’t break stuff. So, things like
{{}}won’t work
We are left with very little options, which are reasonable. With this in mind: please, vote ![]()
- ${}
- f{}
0
voters