Given a simple class:
class MyClassA():
def __init__(self, param_a, param_b):
self.param_a = param_a
self.param_b = param_b
def my_method(self, param_c):
return some_fun(self.param_a, self.param_b)
Now I want to create an instance of this class with just param_b
being set.
Namely something like:
class MyClassB(MyClassA):
def __init__(self, param_a):
super().__init__(param_a, something)
Now I want: my_obj_c = MyClassB(some_val)
.
The question, is there a way to get my_obj_c
in one liner without explicitly building MyClassB
?
Motivation
The reason I need this is actually this class is used by a different procedure which supports calling the class with a single input.
What I want is to try it (like grid search) which many different values of param_b
. This is why setting a default value won't do it.
get my_obj_c
. In your codemy_obj_c
is an instance ofMyClassB
-- that's it's type. Is that what you want, or are you really trying to make aMyClassA
without specifyingparam_b
?A
optional. This would however maintain thetype
ofMyClassA
and notMyClassB