title: How to implement a subscriptable class in Python (subscriptable class, not subscriptable object)?
body: <p>To implement a subscriptable object is easy, just implement <code>__getitem__</code> in this object's class definition.<br/>
  But now I want to implement a subscriptable class. For example, I want to implement this code:</p>
  
  <pre><code>class Fruit(object):
      Apple = 0
      Pear = 1
      Banana = 2
      #________________________________ 
      #/ Some other definitions,         \
      #\ make class 'Fruit' subscriptable. /
      # -------------------------------- 
      #        \   ^__^
      #         \  (oo)\_______
      #            (__)\       )\/\
      #                ||----w |
      #                ||     ||
  
  print Fruit['Apple'], Fruit['Banana']
  #Output: 0 2
  </code></pre>
  
  <p>I know <code>getattr</code> can do the same thing, but I feel subscript accessing is more elegant.</p>