I'm wondering if it is possible at all in python to stringify variable id/symbol -- that is, a function that behaves as follows:
>>> symbol = 'whatever'
>>> symbol_name(symbol)
'symbol'
Now, it is easy to do it on a function or a class (if it is a direct reference to the object):
>>> def fn(): pass
>>> fn.func_name
'fn'
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.
Is there any way to do it?