I'm trying to create a new method for a class from a different file (not the file where the class was defined). My code is:
from derivations import derivation
class Derivation(derivation.Derivation):
def autoderive(self, index):
...
deriv = derivation.Derivation()
But if I try to run this method from the terminal, it doesn't work:
>>> deriv.autoderive()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Derivation' object has no attribute 'autoderive'
I don't have problems with the "native" methods. And I'm working with a fork of this: https://github.com/alexwarstadt/minimalism
Thank you very much.
CodePudding user response:
I do not know much about the derivation
module, but you are not creating an instance of your Derivation
class, where you have defined the autoderive
method, by doing this:
deriv = derivation.Derivation()
To create an instance of your custom class Derivation
, that derives from derivation.Derivation():
deriv = Derivation()