
July 21, 2015
6:22 a.m.
Ryan Gonzalez writes:
I suppose the OP will claim that an explicit call to locals() is verbose and redundant, but if that really is a problem:
def format_with_locals(fmtstr): return fmtstr % locals()
Won't this use the locals of the function format_with_locals over its caller?
Yes, it will. I apologize for posting untested code.