In python3.6, the question of super (), why does super need to add a () when a subclass calls a method of the parent class?

The

extension class inherits from a method behavior of the base class, and then if you want to perform this behavior of the base class again, adding a reference to the base class before your own behavior, why add a parenthesis after super?
just write super.working () and report an error.

also, if you write the name of the base class here, Employee (). Working ()
will also report an error. You can only use super (). Working (), why.

the code is as follows:

class Employee:

def __init__(self,name,department,title,salary):
    self.name = name
    self.department = department
    self.title = title
    self.salary = salary

def __repr__(self):
    return f":{self.name}"

def working(self):
    print(f"{self.name}...")

class Developer (Employee):

def __init__(self,name,department,title,salary,skills):
    Employee.__init__(self,name,department,title,salary)
    self.skills = skills

def working(self):
    super().working()
    print("")

class Accountant (Employee):

def __init__(self,name,department,title,salary,certification):
    Employee.__init__(self,name,department,title,salary)
    self.certification = certification

if name ="_ _ main__":

d = Developer("tom","","","13000",["python","flask"])
print(d.name)
d.working()

Apr.25,2022

    Why is there a parenthesis after
  1. super?
    super is a function, and the call to the function requires parentheses. Directly super.working () is equivalent to calling the working method of the object super, but it does not have this method, so it will report an error.
  2. Employee (). Working () reports an error. Employee (). Working () calls the working method of a class after instantiating it. Instantiating Employe requires passing the parameters name,department,title,salary and changing it to Employee (name=xxx, department=xxx, title=xxx, salary=xxx). Working ().

the calling object's method is followed by parentheses, and the calling object's property
remember these two points. If you want to figure out whether to call the property or the method, you won't be mistaken.


1.super is used to instantiate an object to call the instance method
2. Your call to the base class is invalid because working is an instance method. If you use initialization parameters to pass into the class to generate an instance, your call with the base class should also be

of ok.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b940-40830.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b940-40830.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?