Feb-01-2019, 04:34 PM
When you call SubClass(), that calls the class's __init__ method. Since __init__ is not defined for SubClass, it inherits the one from its parent, SuperClass. The signature for that method is
For more on classes, check out this tutorial.
BTW, where did you get that code from? It's horrible Python code. You never almost never use getters and setters in Python. They slow things down, make your code harder to understand, and don't actually do anything. If you really need that sort of security (as in, self.y must change whenever self.x changes) you use properties. But generally you just don't bother.
def __init__(self, a1, a2):
. The self parameter is automatically supplied by Python, so you only have two parameters left: a1 and a2. You gave three parameters, Python supplied self automatically, so that's four parameters for a method which only has three defined.For more on classes, check out this tutorial.
BTW, where did you get that code from? It's horrible Python code. You never almost never use getters and setters in Python. They slow things down, make your code harder to understand, and don't actually do anything. If you really need that sort of security (as in, self.y must change whenever self.x changes) you use properties. But generally you just don't bother.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures