I'd like to apply partial from functools to a class method.
from functools import partial
class A:
def __init__(self, i):
self.i = i
def process(self, constant):
self.result = self.i * constant
CONST = 2
FUNC = partial(A.process, CONST)
When I try:
FUNC(A(4))
I got this error:
'int' object has no attribute 'i'
It seems like CONST has been exchange with the object A.