tdma
tdma

Reputation: 192

Getting attribute of superclass

class A(object):
    has_access = True

class B(A):
    @property
    def has_access(self):
        if (condition):
            return True
        else:
            return super(B, self).__getattribute__('has_access')

This does not work (goes in an endless loop). Is there any way to access the original value of the inherited object?

Upvotes: 0

Views: 99

Answers (1)

kaveh
kaveh

Reputation: 2146

Try this:

class A(object):
    has_access = True

class B(A):
    @property
    def has_access(self):
        if (condition):
            return True
        else:
            return super(B, self).has_access

Upvotes: 2

Related Questions