<p>I have a function in Python which is iterating over the attributes returned from <code>dir(obj)</code>, and I want to check to see if any of the objects contained within is a function, method, built-in function, etc.  Normally you could use <code>callable()</code> for this, but I don't want to include classes.  The best I've come up with so far is:</p>
<pre><code>isinstance(obj, (types.BuiltinFunctionType, types.FunctionType, types.MethodType))
</code></pre>
<p>Is there a more future-proof way to do this check?</p>
<p><strong>Edit:</strong> I misspoke before when I said: &quot;Normally you could use <code>callable()</code> for this, but I don't want to disqualify classes.&quot;  I actually <em>do</em> want to disqualify classes.  I want to match <em>only</em> functions, not classes.</p>

```
```
if hasattr(obj, '__call__'): pass
```
```
This also fits in better with Python's "duck typing" philosophy, because you don't really care
what
it is, so long as you can call it.
It's worth noting that
```
callable()
```
is being removed from Python and is not present in 3.0.