PEP498 - Literal String Interpolation
February 2, 2018•294 words
I hate myself for not knowing that this PEP has existing for Python 3.6.
While checking out task processing frameworks (mainly dramatiq), I found an example using f-strings and my mouth dropped to the floor.
Previously I was doing a lot of my string formatting using the **locals() trick, which is considered a bad practice.
This trick allows me to auto-format a format string with local variables without too much hassle.
(name, value,) = ('favorite number', 37,)
print('{name} is {value}'.format...
Read post