Let's say I have the following class.
class A:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
obj_A = A(y=2) # Dynamically pass the parameters
My question is, how can I dynamically create an object of a certain class by passing only one (perhaps multiple but not all) parameters? Also, I have prior knowledge of the attributes name i.e. 'x' and 'y' and they all have a default value.
Edit: To clear up some confusion. The class can have any number of attributes. Is it possible to create an instance by passing any subset of the parameters during runtime?
I know I can use getters
and setters
to achieve this, but I'm working on OpenCV python, and these functions are not implemented for some algorithms.