python class properties

Viewed 12887

I'm trying to find the best way to extend a class variable. Hopefully an example of the method I've come up with so far will make this clear.

class A(object):
    foo = ['thing', 'another thing']

class B(A):
    foo = A.foo + ['stuff', 'more stuff']

So I'm trying to make the subclass inherit and extend the parent's class variable. The method above works, but seems a bit kludgey. I'm open to any suggestion, including accomplishing something similar using a completely different approach.

Obviously I can continue to use this method if need be, but if there's a better way I'd like to find it.

2 Answers
Related