AttributeError: ObjectT instance has no attribute '__getitem__'
<pre><code>    &gt;&gt;&gt; dir(classAInstance.objectTInstance.__dict__)
    ['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__',
 '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__',
 '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', 
'__setitem__', '__str__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 
'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']

&gt;&gt;&gt; classAInstance.objectTInstance.attB             # Access Method 1
199

&gt;&gt;&gt; classAInstance.objectTInstance.__dict__['attB'] # Access Method 2
199

&gt;&gt;&gt; classAInstance.objectTInstance['attB']          # Access Method 3
Traceback (most recent call last):
  File "&lt;input&gt;", line 1, in ?
AttributeError: ObjectT instance has no attribute '__getitem__'
</code></pre>

<p>Claim: <code>classAInstance</code> is an insance of <code>ClassA</code> and <code>objectTInstance</code> is an instance of <code>ObjectT</code>.</p>

<p><strong>Question</strong>>where does <code>classAInstance.objectTInstance</code> store the attribute <code>attB</code>?
And why the Access Method 3 doesn't work? what exactly does <code>__dict__</code> store?</p>

<pre><code> object.__dict__
     A dictionary or other mapping object used to store an object’s (writable) attributes.
</code></pre>

<p>Based on my understanding, Access method 1 and 2 are exactly same. Also the <code>attB</code> is stored in the <code>__dict__</code> of the object of <code>ObjectT</code>. In order to make Access 3 work, ObjectT has to provide a dictionary magic function called <code>__getitem__</code>. </p>

<p>Is this correct?</p>

<p>Thank you</p>
