compile error when using override
Ho Yeung Lee
jobmattcon at gmail.com
Thu Dec 1 01:26:30 EST 2016
import ast
from __future__ import division
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)
import inspect
class A:
@staticmethod
def __additionFunction__(a1, a2):
return a1*a2 #Put what you want instead of this
def __multiplyFunction__(a1, a2):
return a1*a2+a1 #Put what you want instead of this
def __init__(self, value):
self.value = value
def __add__(self, other):
return self.__class__.__additionFunction__(self.value, other.value)
def __mul__(self, other):
return self.__class__.__multiplyFunction__(self.value, other.value)
solve([A(x)*A(y) + A(-1), A(x) + A(-2)], x, y)
>>> solve([A(x)*A(y) + A(-1), A(x) + A(-2)], x, y)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 12, in __mul__
TypeError: unbound method __multiplyFunction__() must be called with A instance
as first argument (got Symbol instance instead)
import ast
from __future__ import division
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)
import inspect
class AA:
@staticmethod
def __additionFunction__(a1, a2):
return a1*a2 #Put what you want instead of this
def __multiplyFunction__(a1, a2):
return a1*a2+a1 #Put what you want instead of this
def __init__(self, value):
self.value = value
def __add__(self, other):
return self.__class__.__additionFunction__(self.value, other.value)
def __mul__(self, other):
return self.__class__.__multiplyFunction__(self.value, other.value)
ss = solve(AA)
ss([x*y + -1, x-2], x, y)
>>> ss([x*y + -1, x-2], x, y)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: solve instance has no __call__ method
More information about the Python-list
mailing list