Using global variables between files?

The problem is you defined myList from main.py, but subfile.py needs to use it. Here is a clean way to solve this problem: move all globals to a file, I call this file settings.py. This file is responsible for defining globals and initializing them: # settings.py def init(): global myList myList = [] Next, your … Read more

Are global variables in PHP considered bad practice? If so, why?

Reposted from the ended SO Documentation Beta We can illustrate this problem with the following pseudo-code function foo() { global $bob; $bob->doSomething(); } Your first question here is an obvious one Where did $bob come from? Are you confused? Good. You’ve just learned why globals are confusing and considered a bad practice. If this were … Read more

tech