title: How do I get the same functionality as C's __FUNCTION__ in Python?
body: <p>In C, I can put a log printf inside a function like this:</p>
  
  <pre><code>void xx_lock (int xx_flag)
  {
    printf ("%s: START with %d\n", __FUNCTION__, xx_flag);
  }
  </code></pre>
  
  <p>so I can copy the same line where I need in any function and it displays the function name in the log. I want something similar in Python. But if I use</p>
  
  <pre><code>__name__
  </code></pre>
  
  <p>the same way, it displays the module name, not the function name.</p>
  
  <pre><code>def xxx_lock(xx_flag=0)
      sys.stdout.write("%s: START with %d\n" % (__name__, xx_flag))
  </code></pre>
  
  <p>Is there some simple construct that I can use in that example to show the Python function name? To produce output like this:</p>
  
  <pre><code>xxx_lock: START with 1
  </code></pre>
  
  <p>Edited: added the parameter to the example.</p>