I have a module; say it's structured as:
algorithms
├─ __init__.py
└─ algorithm.py
Inside my algorithm module, I have some global vars, and I would like to create a convenience initializer that sets them up. I would like to use the same names for the initializer's parameters as for the vars, but that leads to a conflict of local and global names. The cleanest way I can think of to implement this is:
lower = None
upper = None
def init_range(lower, upper):
_lower = lower
global lower
lower = _lower
_upper = upper
global upper
upper = _upper
If this were a class, (I think) I could do something like self.lower = lower
. Is there a less verbose way to do what I'm doing for module-global vars? Something like algorithm.lower = lower
?
EDIT: Turns out my solution doesn't work.