It already works! from macropy.string_interp import macros, sA = 10B = 5print s["{A} + {B} = {A + B}"]# 10 + 5 = 15 a, b = 1, 2print s["{a} apple and {b} bananas"]# 1 apple and 2 bananas On Thu, Feb 6, 2014 at 4:11 PM, Chris Angelico <rosuav@gmail.com> wrote:
On Fri, Feb 7, 2014 at 10:41 AM, Robert Hölzl <robert.hoelzl@posteo.de> wrote:
How about introducing new string tokens beginning with 'f', which tells the parser to take over that job. In this case one simply had to write:
f"{name} is {value} ({value:X} in hex)"
and the parser would replace this by
"{name} is {value} ({value:X} in hex)".format( **collections.ChainMap(locals(), globals()) )
PHP programmers would love it. Subsequent maintainers would hate it.
It's way too magical for my liking.
ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/