
On Fri, Aug 19, 2016 at 1:05 AM, Philipp A. <flying-sheep@web.de> wrote:
the embedded expressions are just normal python. the embedded strings just normal strings. you can simply switch between both using <{> and <[format]}>.
The trouble with that way of thinking is that, to a human, the braces contain something. They don't "uncontain" it. Those braced expressions are still part of a string; they just have this bit of magic that gets them evaluated. Consider this:
"This is a number: {:0\u07c4}".format(13) 'This is a number: 0013'
Format codes are just text, so I should be able to use Unicode escapes. Okay. Now let's make that an F-string.
f"This is a number: {13:0\u07c4}" 'This is a number: 0013'
Format codes are still just text. So you'd have to say that the rules of text stop at an unbracketed colon, which is a pretty complicated rule to follow. The only difference between .format and f-strings is that the bit before the colon is the actual expression, rather than a placeholder that drags the value in from the format arguments. In human terms, that's not all that significant. IMO it doesn't matter that much either way - people will have to figure stuff out anyway. I like the idea that everything in the quotes is a string (and then parts of it get magically evaluated), but could live with there being some non-stringy parts in it. My suspicion is that what's easiest to code (ie easiest for the CPython parser) is also going to be easiest for all or most other tools (eg syntax highlighters). ChrisA