I have to create a global variable.
this variable is initialized in the main after an input parameter is passed and then I want to make it available everywhere in the code without passing it in the init of the different objects.
global pulse
def main(shot_no,...):
pulse = shot_no
#create object
signal = Data(constants)
print('here')
print(pulse)
success = signal.read_data(shot_no,...)
within the class Data pulse is defined in the init as global.
Data is a class inherited from another and also in this one I define in the init pulse as global
I get an error "NameError: name 'pulse' is not defined"
any help?
the answer Python variable scope error
doens't answer my question (as a matter of fact there is no actually an answer in that post)