0

When I try:

class A:
    def __init__(self):
        self.flag = False

    def check_flag(self):
        if self.flag: return True
        else: return False

    def create(self):
        b = B()
        b.foobar()

class B(A):
    def __init__(self):
        self.foo = 0

    def foobar(self):
        while super().check_flag() == False:
         `print("Works"`)


if __name__ == "__main__":
    a = A()
    a.create()

I get the error: AttributeError: 'B' object has no attribute 'flag'

I basically want an object B to call a function from its specific parent object A. What am I doing wrong here?

EDIT: I should specify, That the parent object's flag may be changed by a different function, so the child object needs to constantly check what that flag's status is. I may try to use threads but I'm sure there's a simpler way using super().

medik ski
  • 1
  • 1
  • 1

0 Answers0