Dec-03-2019, 10:59 PM
Hello,
I realize this is a very simple question but I have seen some information online that is slightly contradictory on this. How many constructors can a Python class have? Is it that every Python class must have one AND ONLY ONE __init__ constructor? This is not a homework question - just trying to understand this concept from the forum. This doesn't seem to specifically be addressed in the Python docs.
https://docs.python.org/3/reference/data...l#index-69
object.__init__(self[, ...])
Called after the instance has been created (by __new__()), but before it is returned to the caller. The arguments are those passed to the class constructor expression. If a base class has an __init__() method, the derived class’s __init__() method, if any, must explicitly call it to ensure proper initialization of the base class part of the instance; for example: super().__init__([args...]).
Thank you in advance for your help with this newbie question,
crocolicious
I realize this is a very simple question but I have seen some information online that is slightly contradictory on this. How many constructors can a Python class have? Is it that every Python class must have one AND ONLY ONE __init__ constructor? This is not a homework question - just trying to understand this concept from the forum. This doesn't seem to specifically be addressed in the Python docs.
https://docs.python.org/3/reference/data...l#index-69
object.__init__(self[, ...])
Called after the instance has been created (by __new__()), but before it is returned to the caller. The arguments are those passed to the class constructor expression. If a base class has an __init__() method, the derived class’s __init__() method, if any, must explicitly call it to ensure proper initialization of the base class part of the instance; for example: super().__init__([args...]).
Thank you in advance for your help with this newbie question,
crocolicious