class M(object): def __init__(self): self.__getitem__ = lambda self, name: 'Coin' m = M() print m['foo']