python - accessing superclass attributes

17,986

An Sub is a Super, i.e. all instances of Sub can be treated exactly like instances of Super. In your case, that means you simply set self.a = b.

Share:
17,986

Related videos on Youtube

Aly
Author by

Aly

SOreadytohelp

Updated on June 17, 2022

Comments

  • Aly
    Aly about 2 years

    Hi I want to achieve the following in python, however I cant figure out what to replace the line super.a = b with:

    class Super:
      def __init__(self):
        self.a = 1
    
    class Sub(Super):
      def method(self, b):
        super.a = b