title: python introspection - get name of variable passed to function
body: <p>I'd like to be able to access the name of a variable that is passed to a function as e.g.</p>
  
  <pre><code>def f(x):
      '''Returns name of list/dict variable passed to f'''
      return magic(x)
  
  &gt;&gt;a = [1,2,3]
  &gt;&gt;print( f(a) )
  'a'
  &gt;&gt;print( f(2) )
  None
  </code></pre>
  
  <p>I suspect this is possible using Python introspection but I don't know enough to understand the inspect module. (NB I know that the need for a function like magic() is questionable, but it <em>is</em> what I want.)</p>