Created
June 26, 2012 20:10
-
-
Save mikedouglas/2998579 to your computer and use it in GitHub Desktop.
...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import types | |
class Object(object): | |
def __getitem__(self, key): | |
return 2*self.__getitem__(key) | |
obj = Object() | |
obj.__getitem__ = types.MethodType((lambda self, x: x), obj) | |
obj[5] #=> 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment