Best way to use variable across functions in python

82 Views Asked by At

I need to refer to the same variable in several functions in a python script. (The write context of a CGPDFDocument).

I can either write global writeContext in every function;

or add the variable as an argument to every function;

....both of which seem to be excessive duplication.

Other answers to questions about global variables in python suggest that they are "bad". So what's the better way of handling it?

0

There are 0 best solutions below