title: Get the name of a python variable
body: <pre><code>def f(s)
    print &lt;name of s&gt; = s
  </code></pre>
  
  <p>I wish to output "hello=10" for <code>f(hello)</code>, given that the variable hello has value 10.</p>
  
  <p>The problem is how to get the variable name of the variable, i.e., <code>&lt;name of s&gt;</code>?</p>
  
  <p>This is for debugging purpose.
  Say given a new statement <code>s=2</code> </p>
  
  <p><code>f(s)</code> before the new statement will print <code>s=0</code> if <code>s</code> is initially 0, <code>f(s)</code> after the new statement will print <code>s=2</code>.</p>
  
  <p>I can easily write:</p>
  
  <pre><code>def f(name,value)
     print "%s=%s"%(name,str(value))
  </code></pre>
  
  <p>and use it as <code>f("s",s)</code>, but that would need me to input two arguments, which is more cumbersome.</p>