Simulating Multiple Constructors
A pretty useful technique for simulating multiple constructors in a Python class is to provide
.__init__() with optional arguments using default argument values. This way, you can call the class constructor in different ways and get a different behavior each time.
This technique allows you to simulate multiple constructors in a class. You’ll learn the basics of how to simulate multiple ways to construct objects by providing appropriate default values for the arguments of the
.__init__() method and also by checking the data type of the arguments to this method.
Become a Member to join the conversation.