Python getattr() member or function?
<p>I'm trying to use Python's getattr() to extract data out of a number of objects that I got from various APIs that I do not control. My idea was to go through a list of hetrogenous objects and try to getattr() on them until I pull out everything that I need.</p>

<p>So I'm doing one of these:</p>

<pre><code>if hasattr(o, required_field):
    value = getattr(o, required_field)
    result.append([required_field, value])
    print 'found field', field, 'for value', value
</code></pre>

<p>My problem is sometimes the objects I'm dealing with have object.data() and sometiems object.data to pull stuff out. Sometimes these objects are actually generators.</p>

<p>So once in a while I'd get something like this:</p>

<pre><code>found field ValueOfRisk for value
CellBM:&lt;Instrument:/limbo/WLA_YdgjTdK1XA2qOlm8cQ==&gt;.ValueOfRisk&gt;
</code></pre>

<p>Question: is there a way that I can say 'access the data member when it's a data member, or call a function when it's a function' to take the value out of these things? Seems like this should be easy with Python but I can't find it.</p>
