I'm curious about how to declare multiple global variables while adhering to PEP8 guidelines, which recommend limiting each line to a maximum of 79 characters.
According to the global statement documentation defined by the BNF notation statement in the documentation, it seems that there's no built-in support for multi-line declarations like this:
VAR1 = 0
VAR2 = 0
VAR3 = 0
VAR4 = 0
def change(VAR):
global (VAR1, VAR2,
VAR3, VAR4)
pass
So, if I have many global variables to declare, do I have to split them across multiple lines like this?:
def change(VAR):
global VAR1, VAR2
global VAR3, VAR4
pass
I would appreciate any insights or alternative approaches to declaring multiple global variables in line with PEP8 recommendations.
Find the documentation. Hope someone can answer the proble.
That's pretty awkward with so many global variables. Since these globals are settings or configuration values it might be better to move them into their own module and import them:
Alternatively, combine the values into a collection such as a
dictorlist: