Loop through object functions
<p><code>dir(object)</code> returns a list of object attributes and functions. How can I iterate over all callable functions and get the output of the functions? (ASSUMING NO FUNCTION ARGS)</p>

<pre><code>for a in dir(obj) if not a.startswith('__') and callable(getattr(obj,a)):
    response = obj.a()
</code></pre>

<p>This does not work as python is treating a as the attribute name. Is there any way to do this?</p>

<p>you need to use getattr to actually get the callable and then call it ...</p>

<p>do this</p>

<pre><code>fn = getattr(obj,a)
fn()
</code></pre>

<p>not this</p>

<pre><code>obj.a()
</code></pre>

<p>of coarse you are not checking if the callable has any required arguments or anything like that ... im not sure what you are actually trying to accomplish... but im skeptical that this is the right technique</p>

<p>additionally you need one more <code>)</code> on this line  <code>callable(getattr(obj,a):</code></p>

python python-2.7