Answer the question
In order to leave comments, you need to log in
Why can't I access parent class attributes via super() in python?
I have never been a programmer, but sometimes I peep with one eye. It became curious - why is it possible to access the methods and properties of the parent class through super (), but not the attributes?
class User:
count = 0
def __init__(self, n, l, p):
self.__name = n
self.__login = l
self.__password = p
User.count += 1
class SuperUser(User):
count = 0
def __init__(self, n, l, p, role):
super().__init__( n, l, p)
self.__role = role
SuperUser.count += 1
super().count -= 1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question