
On Jul 19, 2015, at 04:35 PM, Mike Miller wrote:
I've long wished python could format strings easily like bash or perl do, ... and then it hit me:
csstext += f'{nl}{key}{space}{{{nl}'
An "f-formatted" string could automatically format with the locals dict.
You might take a look at a feature of flufl.i18n, which supports automatic substitutions from locals and globals: http://flufli18n.readthedocs.org/en/latest/docs/using.html#substitutions-and... In general, flufl.i18n builds on PEP 292 $-strings and gettext to support more i18n use cases, especially in multi-language contexts. Still, the substitution features can be more or less used independently, and do a lot of what you're looking for. This feature is only supported on implementations with sys._getframe() though (e.g. CPython). Cheers, -Barry