7 ms·
I think the point would be to do something like: a = 3 b = 4 c = 6 "A is {a}, C is {c}, B is {b}".format(**locals()) Then you don't have to fi
by x1798DE 12y ago
I think the point would be to do something like:
a = 3
b = 4
c = 6
"A is {a}, C is {c}, B is {b}".format(**locals())
Then you don't have to figure out specifying order or definitions like ".format(a=a, b=b, c=c)". I'd probably go the more explicit route in production code anyway, but for debugging / unstable development it seems useful.
- wodenokoto 12y agoI'm still not convinced. In order to write the string portion of the code, I need to know the names of the variables in play and I have to order them in them in some order in the string regardless. So I still don't think "A is {a}, C is {c}, B is {b}".format(**locals()) is better than "A is {}, C is {}, B is {}".format(a, c, b)