How are you? The NameError occurs because the global statement is incorrectly placed. In Python, the global keyword is used to declare that a variable inside a function refers to a global variable. However, in this case, the variable is being accessed at the class level, not within a function. Therefore, the variable __global_object_in_module is not recognized as a global variable in the context of the class. The solutiona is as follow. To resolve this issue, you can define the global variable outside of the classes and then access it directly without using the global keyword. __global_object_in_module = SharedObject()
class Unit1: _gl_object = __global_object_in_module
class Unit2: _gl_object = __global_object_in_module In this corrected version, the global variable is defined outside the classes, and each class can access it directly as a class variable without the need for the global statement.