I need to define a class which extends python's standard math module, without instantiating it (no need for that, all methods in the class are static):
import math
class more_math(math):
@staticmethod
def add_func(x):
return math.sqrt(x)+1
The code above doesn't run properly (script exits), with the error:
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
When the class declaration above is set to class more_math:
, more_math.add_func(x)
is called without error. However, more_math.sqrt(x)
[sqrt
is a method of math
] can't be called, as more_math
doesn't have math
as its base class.
Ideas on how could this be setup properly?