Mercurial > magic
diff Methods @ 57:e25314562515
created
| author | 127.0.0.1 |
|---|---|
| date | Sat, 29 Jun 2013 12:53:39 +0200 |
| parents | |
| children | a7a67be0697c |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Methods Sat Jun 29 12:53:39 2013 +0200 @@ -0,0 +1,15 @@ +{{{#!python +class UnboundMethod(object): + def __init__(self, func): + self.__func__ = func + def __call__(self, *args, **kwargs): + return self.__func__(*args, **kwargs) + def __get__(self, instance, owner): + return BoundMethod(instance, self.__func__) + +class BoundMethod(object): + def __init__(self, instance, func): + self.__self__, self.__func__ = instance, func + def __call__(self, *args, **kwargs): + return self.__func__(self.__self__, *args, **kwargs) +}}} \ No newline at end of file
