Python Forum
super() and order of running method in class inheritance
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
super() and order of running method in class inheritance
#7
(Feb-02-2024, 09:01 AM)Gribouillis Wrote:
(Feb-02-2024, 08:10 AM)akbarza Wrote: but still, i don't know why Python in line 22 goes to child2-form1 .
That's because you read the documentation but you don't understand it.

At line 22, python will run super(child1, self).form1() . It means that it will search and call method form1() in the part of the __mro__ of self that comes after child1. This part of the __mro__ is child2 -> parent -> object. As there is a method named form1() in child2, it is this method that gets called.

hi
in the code there is super().form1() . you said
Quote:At line 22, python will run super(child1, self).form1()
. how does Python recognize this argument for super() in that line?
Reply


Messages In This Thread
RE: super() and order of running method in class inheritance - by akbarza - Feb-04-2024, 06:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems with super() Hoespilaar 3 540 Jun-11-2024, 02:15 AM
Last Post: kanetracy
  class definition and problem with a method HerrAyas 2 441 Apr-01-2024, 03:34 PM
Last Post: HerrAyas
  super() in class akbarza 1 721 Dec-19-2023, 12:55 PM
Last Post: menator01
  the order of running code in a decorator function akbarza 2 686 Nov-10-2023, 08:09 AM
Last Post: akbarza
  "Name is not defined" when running a class lil_e 6 4,690 Jan-12-2023, 11:57 PM
Last Post: lil_e
  Using one child class method in another child class garynewport 5 1,861 Jan-11-2023, 06:07 PM
Last Post: garynewport
  Child class inheritance issue eakanathan 3 1,510 Apr-21-2022, 12:03 PM
Last Post: deanhystad
  [Solved] Novice question to OOP: can a method of class A access attributes of class B BigMan 1 1,436 Mar-14-2022, 11:21 PM
Last Post: deanhystad
  class, attribute and method Frankduc 9 2,775 Feb-27-2022, 09:07 PM
Last Post: deanhystad
  Subclass initialized property used in parent class method. Is it bad coding practice? saavedra29 5 2,099 Feb-07-2022, 07:29 PM
Last Post: saavedra29

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020