title: How can I get the name of an object?
body: <p>Is there any way to get the name of an object in Python?  For instance:</p>
  
  <pre><code>my_list = [x, y, z] # x, y, z have been previously defined
  
  for bla in my_list:
      print "handling object ", name(bla) # &lt;--- what would go instead of `name`?
      # do something to bla
  </code></pre>
  
  <p><strong>Edit:</strong> Some context:</p>
  
  <p>What I'm actually doing is creating a list of functions that I can specify by the command line.</p>
  
  <p>I have:</p>
  
  <pre><code>def fun1:
      pass
  def fun2
      pass
  def fun3:
      pass
  
  fun_dict = {'fun1': fun1,
              'fun2': fun2,
              'fun3': fun3}
  </code></pre>
  
  <p>I get the name of the function from the commandline and I want to call the relevant function:</p>
  
  <pre><code>func_name = parse_commandline()
  
  fun_dict[func_name]()
  </code></pre>
  
  <p>And the reason I want to have the name of the function is because I want to create <code>fun_dict</code> without writing the names of the functions twice, since that seems like a good way to create bugs.  What I want to do is:</p>
  
  <pre><code>fun_list = [fun1, fun2, fun3] # and I'll add more as the need arises
  
  fun_dict = {}
  [fun_dict[name(t) = t for t in fun_list] # &lt;-- this is where I need the name function
  </code></pre>
  
  <p>This way I only need to write the function names once.</p>