Hey. I have two Python modules:
Unloader.py
and
GetRequest.py
In a script implemented in Unloader.py, a function is called that is in GetRequest.py. In addition, a global variable is declared in Unloader.py, which is used in the above function from GetRequest.py. But for some reason, this global variable is invisible:
NameError: global name 'countFailResponse' is not defined I will give an example
Unloader.py:
global countNullResponse response, isGetData = GetRequests.Request(query) GetRequest.py:
def Request(query): global countNullResponse countNullResponse += 1 How to fix the code so that Request see the global variable countNullResponse ?
globaldoes not quite work like this) is a variable declared in the module (script) at the lowest level (without indents) and global is used inside the functions in the modules so that you can assign the value of that variable, because if you do not specifyglobala new one will be created variable in the scope of the function. Details and more examples I think right now will tell @jfs))) - gil9red