title: Getting name of a variable in Python
body: <p>If I have local/global variable <code>var</code> of any type how do I get its name, i.e. string <code>&quot;var&quot;</code>? I.e. for some imaginary function or operator <code>nameof()</code> next code should work:</p>
  <pre><code>var = 123
  assert nameof(var) == &quot;var&quot;
  </code></pre>
  <p>There's <code>.__name__</code> property for getting name of a function or a type object that variable holds value of, but is there anything like this for getting name of a variable itself?</p>
  <p>Can this be achieved without wrapping a variable into some magic object, as some libraries do in order to get variable's name? If not possible to achieve without magic wrappers then what is the most common/popular wrapping library used for this case?</p>