Inherited class variable modification in Python

Assuming you want to have a separate list in the subclass, not modify the parent class’s list (which seems pointless since you could just modify it in place, or put the expected values there to begin with):

class Child(Parent):
    foobar = Parent.foobar + ['world']

Note that this works independently of inheritance, which is probably a good thing.

Leave a Comment