Can someone explain what is happening here?
class Test(object):
__getitem__ = getattr
t = Test()
t['foo']
gives error (in Python 2.7 and 3.1):
TypeError: getattr expected at least 2 arguments, got 1
whereas:
def f(*params):
print params # or print(params) in 3.1
class Test(object):
__getitem__ = f
prints the two parameters I'd expect.