Q:

Remove attribute from subclass in Python

Is there any way to remove an attribute from a subclass that is present in the parent?
In the following example
class A(object):
    foo = 1
    bar = 2

class B(A):
    pass

# <desired code here>

b = B()
assert hasattr(b, 'bar') == False

Is there any code we can write to make the assertion pass?

A:

class A(object):
    foo = 1
    bar = 2

class B(A):
    @property
    def bar(self):
        raise AttributeError

>>> b = B()
>>> b.bar

Traceback (most recent call last):
  File "<pyshell#17>", line 1, in <module>
    b.bar
  File "<pyshell#15>", line 4, in bar
    raise AttributeError
AttributeError

