
After I read Nick's proposal and pondering over the 'f' vs. 'r' examples, I like the 'i' prefix more (regardless of the internal implementation). The best solution would be "without prefix and '{var}' only" syntax. Not sure if that is possible at all; I cannot remember using '{...}' anywhere else than for formatting. On 09.08.2015 19:22, Eric V. Smith wrote:
On 8/8/2015 9:08 PM, Tim Delaney wrote:
On 8 August 2015 at 11:39, Eric V. Smith <eric@trueblade.com <mailto:eric@trueblade.com>> wrote:
Following a long discussion on python-ideas, I've posted my draft of PEP-498. It describes the "f-string" approach that was the subject of the "Briefer string format" thread. I'm open to a better title than "Literal String Formatting".
I need to add some text to the discussion section, but I think it's in reasonable shape. I have a fully working implementation that I'll get around to posting somewhere this weekend.
>>> def how_awesome(): return 'very' ... >>> f'f-strings are {how_awesome()} awesome!' 'f-strings are very awesome!'
I'm open to any suggestions to improve the PEP. Thanks for your feedback.
I'd like to see an alternatives section, in particular listing alternative prefixes and why they weren't chosen over f. Off the top of my head, ones I've seen listed are:
! $ I'll add something, but there's no particular reason. "f" for formatted, along the lines of 'r' raw, 'b' bytes, and 'u' unicode.
Especially when you want to combine them, I think a letter looks better: fr'{x} a formatted raw string' $r'{x} a formatted raw string'
Eric.
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/srkunze%40mail.de