title: How to make Python 2's __getitem__ work on a class?
body: <p>How do I make item access ie. <a href="https://docs.python.org/2/reference/datamodel.html#object.__getitem__" rel="nofollow"><code>__getitem__</code></a> available on a class object in Python 2.x?</p>
  
  <p>I've tried:</p>
  
  <pre><code>class B:
      @classmethod
      def __getitem__(cls, key):
          raise IndexError
  </code></pre>
  
  <p>test:</p>
  
  <pre><code>B[0]
  # TypeError: 'classobj' object has no attribute '__getitem__'
  print B.__dict__
  # { ... '__getitem__': &lt;classmethod object at 0x024F5E70&gt;}
  </code></pre>
  
  <p><strong>How do I make <code>__getitem__</code> work on the class itself?</strong></p>