How to get attributes from parent?

Posted by bribon on Stack Overflow See other posts from Stack Overflow or by bribon
Published on 2010-12-21T17:30:46Z Indexed on 2010/12/21 17:54 UTC
Read the original article Hit count: 147

Filed under:

Hi all,

Let's say we have these classes:

class Foo(object):
    _bar = ""

    def __init__(self):
        self.bar = "hello"

    def getBar(self):
        return self._bar

    def setBar(self, bar):
        self._bar = bar

    def getAttributes(self):
        for attr in self.__dict__:
            print attr

    bar = property(getBar, setBar)

class Child(Foo):

    def __init__(self):
        super(Child, self).__init__()
        self.a = ""
        self.b = ""

if I do something like:

child = Child()
child.getAttributes()

I get all the attributes from parent and child. How could I get the attributes only from the parent?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about python