I would like to print variables values in python. e.g:
a=3
b=5
print 'blah blah: a = {a}, b = {b}'.format(a=a, b=b)
result is:
blah blah: a = 3, b = 5
My question is how to do it in a short elegant and readable manner.
e.g., is there a way to write something like (pseudo code below)
print 'blah blah: {a}, {b}'.format(a,b)
to get the same result?
Thanks! (BTW: i am using python 2.7)
EDIT (clarification): For logging purpose, sometimes i have many variables that i would like to print, so i prefer not doing something like
print 'a={}, b={}, c={},...'.format(a,b,c...)
because it is a source for bugs (i.e. I just want to specify the varaible name in the string itself and not care about the order of the variables).
e.g., ultimatly, something that looks like
print 'blah blah: {a}, {b}, {c}, {d}, {e}, {f}'.format(c,e,a,f,d,b)
with a result like:
blah blah: a=3, b=5, c=7, d=22, e=2, f=532