Making multiple variables global in a function

Viewed 44

I have multiple functions that all need to utilize many of the same variables that are defined at the start of the code.

In order to shorten the code a little I wanted to make some form of function to globalise all variables in one go:

def MyGlobals():
    global example1
    global example2
    global example3

Sadly, whenever the function goes to its next step, I get an error message saying that these variables are not defined.

Previously just making the variable global was enough because the variables are defined as the code starts, putting the variable values inside of MyGlobals() did not resolve the issue either.

0 Answers
Related