I am new in python and please excuse me if my question is a basic question or is not clear.
I have a class in python and I want to set some attributes for my objects whenever I generate my objects from this class. I know, I must use __init__
method for this purpose.
The problem is that I want to have this ability that I can set my attributes in two ways. For some of my objects, I want to pass some values to __init__
method and set the attributes with those values. In addition, for some objects, I want to set some default values for attributes of my objects in __init__
method.
My question: How can I have an __init__
method that for some objects uses passed values for setting its attributes, and for some other objects, that are not passed, use default values?