Re: [Python-ideas] String interpolation for all literal strings

Aug. 10, 2015
7:49 a.m.
2015-08-07 9:33 GMT+02:00 Nick Coghlan <ncoghlan@gmail.com>:
If f-strings are always eagerly interpolated prior to translation, then I can foresee a lot of complaints from folks asking why this doesn't work right:
print(_(f"This is a translated message with {a} and {b} interpolated"))
What if we decide to lazy-interpolate f-strings? A creation of such an f-string, creates an f-string object. (Which has a proper __repr__, so that it's transparent for those that don't care.) Calling the __str__ method of the f-string triggers the interpolation. This should give enough freedom to implement a working ugettext. (But I still don't see any reason to go beyond supporting more than just is simple variable name between the curly braces...)
3487
Age (days ago)
3487
Last active (days ago)
0 comments
1 participants
participants (1)
-
Jonathan Slenders