this question is not a duplicate of the other overloading question because I am attempting to reference self.args
in the function. The answer given in that question does not satisfy, since if I implement that answer, I will get an error. However, in other languages, this is easily done through method overloading...so this question is highly related to the other question.
So I have a method,
class learner():
def train(a ton of arguments):
self.argA = argA,
etc.
And I want to call train with just one value, and have it use all the self calls to populate the other arguments...but it is a circular reference that python doesn't seem to support. Ideally, I would write:
class learner():
def train(self, position, data = self.data, alpha = self.alpha, beta = etc):
...do a bunch of stuff
def roll_forward(self,position):
self.alpha += 1
self.beta += 1
self.train(position)
How would I do this? In other languages, I could just define a second train
function that accessed the internal variables...
currently, I have a janky hack where I do this:
class learner():
def train(...):
....
def train_as_is(self,position):
self.train(position,self.alpha,self.beta, etc.)
But this is a pretty big class, and a ton of functions like that are turning my code into spaghetti...