So I have this code (parent class in file_1.py):
class do_something():
def __init__(self, day, month, year):
self.day = day
self.month = month
self.year = year
def set_message(self, s):
global var_1_global
self.var_1 = var_1_global
which is inherited by child class (in file_2.py) like that:
from file_1 import do_something
var_1_global = ""
class child_do_something(...,do_something,..):
...
The code is much larger, but I cannot put it in stackoverflow. I put only the key code. So the error I get is this:
NameError: name 'var_1_global ' is not defined
and shows the line in parent class (file_1.py) and more specifically:
self.var_1 = var_1_global
I have searched and found this: python derived class call a global variable which initialized in superclass which does not help. Any idea what I am missing here and how to fix it?