Lele, I'm afraid I was unclear. The ... in the code snippet was intended to imply that these lines were appended to the end of the original code, where d was defined.
-Ken On 05/14/2018 12:30 AM, Lele Gaifax wrote: > Ken Kundert <then...@nurdletech.com> writes: > >> I tried adding k and v to the local namespace: >> >> ... >> k = 6 >> v = 9 >> print(f'Email: {d:{{k}} {{v}}}') >> >> I still got: >> >> NameError: name 'k' is not defined > > This is not what I get: > > Python 3.6.5 (default, May 11 2018, 13:30:17) > [GCC 7.3.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> k=1 > >>> v=2 > >>> print(f'this is {{k}} and {{v}}') > this is {k} and {v} > >>> print(f'this is {k} and {v}') > this is 1 and 2 > >>> print(f'Email: {d:{{k}} {{v}}}') > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > NameError: name 'd' is not defined > > ciao, lele. > -- https://mail.python.org/mailman/listinfo/python-list