I have a class GUI defined as follows:
table_color = "red"
class GUI:
def __init__(self):
self.draw_table()
def draw_table(self):
print "table color: ", table_color
and I want to define a child class GUI_child based on GUI:
table_color = "blue"
class GUI_child(GUI):
def __init__(self):
GUI.__init__(self)
However the above GUI_child does not work and prints "red". I have a bunch of variables like table_color that are only used once at initialization. I know I can define table_color as a class variable, or define draw_table() again in GUI_child, but feel that these may not be the best option.
(Edit: Since these variables are used only once and I am not going to change or access them, setting them as class variables seems redundant. If I redefine the draw_table() it will just be copy-paste, which in my perspective is not a good practice either.)
What is the best practice for such usage?