Mercurial > magic
annotate Methods @ 57:e25314562515
created
| author | 127.0.0.1 |
|---|---|
| date | Sat, 29 Jun 2013 12:53:39 +0200 |
| parents | |
| children | a7a67be0697c |
| rev | line source |
|---|---|
| 57 | 1 {{{#!python |
| 2 class UnboundMethod(object): | |
| 3 def __init__(self, func): | |
| 4 self.__func__ = func | |
| 5 def __call__(self, *args, **kwargs): | |
| 6 return self.__func__(*args, **kwargs) | |
| 7 def __get__(self, instance, owner): | |
| 8 return BoundMethod(instance, self.__func__) | |
| 9 | |
| 10 class BoundMethod(object): | |
| 11 def __init__(self, instance, func): | |
| 12 self.__self__, self.__func__ = instance, func | |
| 13 def __call__(self, *args, **kwargs): | |
| 14 return self.__func__(self.__self__, *args, **kwargs) | |
| 15 }}} |
