title: Dynamically use class attribute and reusable function
body: <p>I am trying to achieve the following (simplified from real code)</p>
  
  <pre><code>def _do_something(o1, o2, keyatt):
     x = o1.keyatt
     y = o2.keyatt
     return x == y
  
  _do_something(srcObj, destObj, a)
  _do_something(srcObj, destObj, b)
  </code></pre>
  
  <p>Where both objects are of the same class that have 'a' and 'b' attributes</p>
  
  <p>Not sure how to pass the attributes so they are dynamically associated to the o1 and o2.</p>
  
  <p>I tried <code>_do_something(srcObj, destObj, 'a')</code> but I get attribute error.
  I also tried modifying <code>_do_something</code> to used subscripts (i.e. <code>o1[keyatt]</code> but that throws a TypeError that the object is not sub-scriptable.</p>
  
  <p>Is this even possible in Python? (I'm fairly new to the language.)</p>