Python Forum
Base class variables are not accessible
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Base class variables are not accessible
#1
Hi,

I just want to understand, why I'm getting below error in inheritance?
Error:
Traceback (most recent call last): File "inheritance.py", line 13, in <module> main() File "inheritance.py", line 10, in main print b_obj.aa AttributeError: 'B' object has no attribute 'aa'
This is my python code
class A(object):
    def __init__(self):
        self.aa = None

class B(A):
    def __init__(self):
        self.bb = None
def main():
    b_obj = B()
    print b_obj.aa

if __name__ == '__main__':
    main()
Reply


Messages In This Thread
Base class variables are not accessible - by Prabakaran141 - Oct-31-2018, 01:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unchangeable variables in a class? Calab 12 1,678 Sep-15-2023, 07:15 PM
Last Post: deanhystad
  Global variables or local accessible caslor 4 1,071 Jan-27-2023, 05:32 PM
Last Post: caslor
  Calling a base class variable from an inherited class CompleteNewb 3 1,751 Jan-20-2022, 04:50 AM
Last Post: CompleteNewb
  Class variables and Multiprocessing(or concurrent.futures.ProcessPoolExecutor) Tomli 5 3,959 Nov-12-2021, 09:55 PM
Last Post: snippsat
  How to pass variables from one class to another hobbyist 18 10,987 Oct-01-2021, 05:54 PM
Last Post: deanhystad
  Acess variables from class samuelbachorik 3 1,930 Aug-20-2021, 02:55 PM
Last Post: deanhystad
  Importing issues with base class for inheritance riccardoob 5 4,796 May-19-2021, 05:18 PM
Last Post: snippsat
  Behavior of Abstract Base Class dgrunwal 4 2,241 Oct-15-2020, 07:19 PM
Last Post: Gribouillis
  Class variables menator01 2 2,048 Jun-04-2020, 04:23 PM
Last Post: Yoriz
  How to make Python 3.7.6 accessible to users Doguhan 4 2,831 May-19-2020, 05:36 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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