How do I make item access ie. __getitem__ available on a class object in Python 2.x?
I've tried:
class B:
@classmethod
def __getitem__(cls, key):
raise IndexError
test:
B[0]
# TypeError: 'classobj' object has no attribute '__getitem__'
print B.__dict__
# { ... '__getitem__': <classmethod object at 0x024F5E70>}
How do I make __getitem__ work on the class itself?
Bis an old-style class, but the important thing here is the special methods I see.@classmethoddecorators (or any other descriptors) either.