PEP 498 adds a new string prefix which allows simpler string formatting by embedding expressions inside string literals. The expressions are evaluated and inserted into the resulting string value: >>> import datetime >>> name = 'Fred' >>> age = 50 >>> anniversary = datetime.date(1991, 10, 12) >>> f'My name is {name}, my age next year is {age+1}, my anniversary is {anniversary:%A, %B %d, %Y}.' 'My name is Fred, my age next year is 51, my anniversary is Saturday, October 12, 1991.' There's been a lot of discussion about this on python-ideas, much of which has been incorporated in to the PEP. Now I feel it's ready for python-dev input. Note there's a companion PEP 501 which extends this idea by delaying converting the expression into a string. This allows for more control over how the expressions are converted in to strings, and allows for non-string conversions as well. I have a complete implementation of PEP 498. I'll shortly create an issue and attach the patch to it. -- Eric.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4