from functools import partial def func return partial func 42 class ob

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from functools import partial
def A(func):
return partial(func, 42)
class B(object):
def a(self):
return self.b(0)
@A
def b(self, c, d):
return c, d
@A
def b(c, d):
return c,d
print b(0)
print B().a()
[mag@frontier:~]1% python b.py
(42, 0)
Traceback (most recent call last):
File "b.py", line 19, in <module>
print B().a()
File "b.py", line 7, in a
return self.b(0)
TypeError: b() takes exactly 3 arguments (2 given)
[mag@frontier:~]1%