정수에 대해 n 값을 만들려고합니다. 내가 생각하고있는 디자인은 다음과 같다. 내가 만들고 클래스 정의 헤더 때는 isNaN 람다 기능이 필요하지만 오류클래스 헤더의 lambda 함수
import numpy as np
class Integer(object):
type = int
nan = -1
isnan = lambda val: val==-1
def __new__(cls, value):
return cls.type(value)
class Float(object):
type = float
isnan = lambda val: np.isnan(val)
def __new__(cls, value):
return cls.type(value)
를 반환하지만
>> Integer.isnan(1)
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>>TypeError: unbound method <lambda>() must be called with Integer instance as first argument (got int instance instead)