title: Dynamically get dict elements via getattr?
body: <p>I want to dynamically query which objects from a class I would like to retrieve. <strong>getattr</strong> seems like what I want, and it performs fine for top-level objects in the class. However, I'd like to also specify sub-elements.</p>
  
  <pre><code>class MyObj(object):
      def __init__(self):
          self.d = {'a':1, 'b':2}
          self.c = 3
  
  myobj = MyObj()
  val = getattr(myobj, "c")
  print val # Correctly prints 3
  val = getattr(myobj, "d['a']") # Seemingly incorrectly formatted query
  print val # Throws an AttributeError
  </code></pre>
  
  <p>How can I get the object's dictionary elements via a string?</p>