global
statement detected PYL-W0603197_sdk_version = None
198
199def _get_device_sdk_version():
200 global _sdk_version201 # Return the cached value, if available
202 if _sdk_version is not None:
203 return _sdk_version
46
47# This method will be invoked only if testpythoninstallation is passed
48def test_binary(testpythoninstallation):
49 global _TEST_PYTHON_INSTALLATION 50 if testpythoninstallation:
51 _TEST_PYTHON_INSTALLATION = True
52
4
5
6def set_verbose(enabled):
7 global __VERBOSE_MODE 8 __VERBOSE_MODE = enabled
9
10
It is recommended not to use global
statement unless it is really necessary. Global variables are dangerous because they can be simultaneously accessed from multiple sections of a program. This frequently results in bugs. This also make code difficult to read, because they force you to search through multiple functions or even modules just to understand all the different locations where the global variable is used and modified. Read more about why it should be avoided here.