0

Why would you use super() like this? What does it actually do?

class Myclass: def __init__(self, item): super().__init__()

15th Nov 2019, 9:13 AM
Theuns Booysen
Theuns Booysen - avatar
8 Respuestas
+ 2
Thanks everyone, for the help and answers. Deleted the super() line and the code is stil going 100%...
16th Nov 2019, 8:11 AM
Theuns Booysen
Theuns Booysen - avatar
+ 1
I don’t think it makes any sense to use `super` when there is no inheritance of class.
15th Nov 2019, 2:40 PM
o.gak
o.gak - avatar
+ 1
agree with o.gak , super() is to be used only if you want to call the properties/ methods of the parent class. Without a parent class it is purposeless
16th Nov 2019, 8:08 AM
Anushka Mehta
0
It should be like this. class MyClass(ParentCls): def __init__(self, prop_of_parent, prop_of_mine): super().__init__(prop_of_parent) self. prop_of_mine = prop_of_mine
15th Nov 2019, 12:28 PM
o.gak
o.gak - avatar
0
There is NO parent class. Myclass is the only class in the code...
15th Nov 2019, 12:45 PM
Theuns Booysen
Theuns Booysen - avatar
0
I know that one class can inherit from another class, but this is not the case.... See the fulk code https://code.sololearn.com/c50xf0qK6C42/?ref=app
15th Nov 2019, 12:58 PM
Theuns Booysen
Theuns Booysen - avatar
0
Actually all classes in Python inherit from class Object how I remember. So... This class in any case should have parents. Or do i remember it wrong?
15th Nov 2019, 1:52 PM
Stanislav
Stanislav - avatar