title: How do I detect whether a Python variable is a function?
body: <p>I have a variable, <code>x</code>, and I want to know whether it is pointing to a function or not.</p>
  
  <p>I had hoped I could do something like:</p>
  
  <pre><code>&gt;&gt;&gt; isinstance(x, function)
  </code></pre>
  
  <p>But that gives me:</p>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in ?
  NameError: name 'function' is not defined
  </code></pre>
  
  <p>The reason I picked that is because</p>
  
  <pre><code>&gt;&gt;&gt; type(x)
  &lt;type 'function'&gt;
  </code></pre>