0

In addition to b class 2 has a c parameter, is this the correct way to code?

class 1: def __init__(self, a, b): self.a = a self.b = b class 2(1): def__init__(self, b, c): super().__init__(b, b) self.c = c

20th May 2022, 2:08 PM
Lenoname
3 Answers
+ 2
class names can't start with a number. Other than that everything seems fine to me.
20th May 2022, 3:47 PM
Sandeep
Sandeep - avatar
+ 1
Sandeep i tried to instantiate it but it failed: class x: def __init__(self, a, b): self.a = a self.b = b class y(x): def__init__(self, b, c): super().__init__(b, b) self.c = c S = y(1, 4) print(S.c)
20th May 2022, 5:17 PM
Lenoname
+ 1
Lenoname there is a typo in class y, __init__ constructor add a space after 'def' keyword
21st May 2022, 1:42 AM
Sandeep
Sandeep - avatar