I am reading through Python and came across various ways to somehow perform overloading in Python(most of them suggested use of @classmethod). But I am trying to do something like this as shown in below code. I have kept all the parameters required in the init method itself. What all possible problems may arise from my choice of overloading?
class Vehicle(object):
def __init__(self, wheels=None, engine=None, model=None):
print("A vehicle is created")
self.w = wheels
self.e = engine
self.m = model
Now I can create any number of Vehicle objects with different parameters each time. I can say something like:
v = Vehicle(engine=2, wheels='Petrol')
v2 = Vehicle(4, 'Diesel', 'Honda')
or even
v3 = Vehicle()
And later I can say something like v3.w = 10 #for truck
and it still works.
So my question is: Is it correct way of overloading apart from @classmethod? What difficulties can I run in later down the path if I use this kind of code?