Python Forum
Why Can't I call base class function for my derived class object?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why Can't I call base class function for my derived class object?
#1
Hi experts!
Any idea if I am making an error in my code as I am not able to understand Why Can't I call the the base class function for my derived class object?
class My_base_class():
    def __init__(self):
        print("This is __init__function of Base Class")
    def base_class_func1(self):
        print("my base class function")
    def base_class_func2(self):
        print("my base class function # 2")     
       
class My_derived_class():
    def __init__(self):
        My_base_class.__init__(self)
        print("I am inside my __init__function of my Drived Class")
    def base_class_func1(self):
        print("my base class function")    
    def derived_class_func1(self):
        print("I am inside my derived class function 01")
        
my_inherit=My_derived_class()
my_inherit.base_class_func2()# I get error while I call function of base class.
Error:'My_derived_class' object has no attribute 'base_class_func2'
Reply


Messages In This Thread
Why Can't I call base class function for my derived class object? - by AmirAB - Feb-13-2019, 06:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Class and methods ebn852_pan 15 953 May-23-2024, 11:57 PM
Last Post: ebn852_pan
  [SOLVED] [listbox] Feed it with dict passed to class? Winfried 3 388 May-13-2024, 05:57 AM
Last Post: Larz60+
  Class and methods Saida2024 2 360 May-13-2024, 04:04 AM
Last Post: deanhystad
  How does this code create a class? Pedroski55 6 722 Apr-21-2024, 06:15 AM
Last Post: Gribouillis
  class definition and problem with a method HerrAyas 2 410 Apr-01-2024, 03:34 PM
Last Post: HerrAyas
  Printing out incidence values for Class Object SquderDragon 3 485 Apr-01-2024, 07:52 AM
Last Post: SquderDragon
  class and runtime akbarza 4 544 Mar-16-2024, 01:32 PM
Last Post: deanhystad
  Operation result class SirDonkey 6 732 Feb-25-2024, 10:53 AM
Last Post: Gribouillis
  The function of double underscore back and front in a class function name? Pedroski55 9 940 Feb-19-2024, 03:51 PM
Last Post: deanhystad
  super() and order of running method in class inheritance akbarza 7 973 Feb-04-2024, 09:35 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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