My question was not about printing a Dictionary.
What I want is, is there any way to print variable names along with values in Python?
Say I have the following C code snippet
typedef long long int ll;
#define getName(var) #var
#define debug(var) fprintf(stderr,"%s = %lld\n",getName(var),((ll)var));
int num = 5;
for(int iter = 0; iter<num; iter++)
There is nothing printed to stdout, but the following is printed to stderr.
iter = 0
iter = 1
iter = 2
iter = 3
iter = 4
In the same way, I would use stderr in python, but the syntax is little big.
from sys import stderr
for iter in range(5):
stderr.write("iter = "+str(iter)+'\n')
Even this code would write the same to stderr. But see the way I wrote it in C vs in python.
I need a simpler way to do this, if possible.
Please help @carre, @sebastian, @ssrivastava990