2 ms·
Actually, if you reference 'a' at all in bar, it will work: def foo(): a = 4 def bar(): a print("a = {a}".format(**
by fragmede 12y ago
Actually, if you reference 'a' at all in bar, it will work:
def foo():
a = 4
def bar():
a
print("a = {a}".format(**locals()))
bar()
foo()
successfully prints
a = 4
which is a bit confusing, but makes sense if you think about it.