Any way to stringify a variable id / symbol in Python?
<p>I'm wondering if it is possible at all in python to stringify
variable id/symbol -- that is, a function that behaves as follows:</p>

<pre><code>&gt;&gt;&gt; symbol = 'whatever'
&gt;&gt;&gt; symbol_name(symbol)
'symbol'
</code></pre>

<p>Now, it is easy to do it on a function or a class (if it is a
direct reference to the object):</p>

<pre><code>&gt;&gt;&gt; def fn(): pass
&gt;&gt;&gt; fn.func_name
'fn'
</code></pre>

<p>But I'm looking for a general method that works on all cases,
even for indirect object references.  I've thought of somehow
using id(var), but no luck yet.</p>

<p>Is there any way to do it?</p>
