|
57
|
1 {{{#!python
|
|
|
2 class UnboundMethod(object):
|
|
|
3 def __init__(self, func):
|
|
|
4 self.__func__ = func
|
|
58
|
5
|
|
57
|
6 def __call__(self, *args, **kwargs):
|
|
|
7 return self.__func__(*args, **kwargs)
|
|
58
|
8
|
|
57
|
9 def __get__(self, instance, owner):
|
|
|
10 return BoundMethod(instance, self.__func__)
|
|
|
11
|
|
|
12 class BoundMethod(object):
|
|
|
13 def __init__(self, instance, func):
|
|
|
14 self.__self__, self.__func__ = instance, func
|
|
58
|
15
|
|
57
|
16 def __call__(self, *args, **kwargs):
|
|
|
17 return self.__func__(self.__self__, *args, **kwargs)
|
|
|
18 }}} |