0

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?

benwiggy
  • 1,440
  • 17
  • 35

0 Answers0