I have looked at What is a clean pythonic way to have multiple constructors in python, but I need further assistance since I'm still a newbie. The example there is when you have just one parameter, and I have four.
Let's say that I have a class:
class Word:
def __init__(self, wordorphrase, explanation, translation, example):
self.wordorphrase = wordorphrase
self.explanation = explanation
self.example = example
self.translation = translation
Now I can create Word objects only by passing four parameters when creating an object, for instance:
w = Word(self.get_word(), self.get_explanation(), self.get_translation(), self.get_example())
How should I modify my __init__
method so that I can create objects by:
w = Word()