3 ms·
I'm disappointed in the interpolated strings. We finally get them, but its already behind the curve compared to Scala or C#, due to not being lazy and allowing
by kazagistar 10y ago
I'm disappointed in the interpolated strings. We finally get them, but its already behind the curve compared to Scala or C#, due to not being lazy and allowing context sensitive string interpolation.
The better design binds the values to the string, but does not interpolate into a string type fully. Then, the resulting object can be passed to a consumer like an SQL engine (and appropriately escaped) or an internationalization library (and swapped out for a translated string before interpolation).
I mean, I appreciate what they did, but it seems like missing a massive opportunity to provide a linguistic building block for library authors.
- mixmastamyk 10y agoThese ideas were discussed at length, but it was ultimately decided to keep things simple. Perhaps the mechanism can be extended in the future? In the meantime the 90% case is supported.
- renzon 10y agoFor i18n you can still do the same of _('your template here {foo}'), where _ is you gettext[1]. And once it has a lazy version, you will be covered. [1] https://docs.python.org/2/library/gettext.html#gnu-gettext-api https://docs.python.org/2/library/gettext.html#gnu-gettext-a...
- masklinn 10y agoThat doesn't work, unless `_` is a gettext overlay which goes and reaches into its caller stackframe and performs string interpolation itself. Otherwise you mean that you can "still do the same of" _('your template here {foo}').format(foo=foo) which is a step down from f'your template here {foo}'