In my remote camera robot project, I have certain variables, declared globally, that (in theory) should be “const(variable = xyz)” such that “variable” cannot be modified elsewhere in the code.
I have four global variables:
vcenter = “x”
hcenter = “y”
vposition = vcenter
hposition = hcenter
Where “x” and “y” are variables determined experimentally and represent the “centered” or resting state of both of Charlie’s head servos.
vcenter and hcenter should be immutable constant values that define the “resting” position of Charlie’s head. In other words, no matter where Charlies head is pointing, setting the horizontal and vertical positions to “hcenter” and “vcenter” will always return Charlie’s head to it’s normal looking straight ahead position.
The issue is that I, (and perhaps others), that work on my programs are supposed to set (adjust) what is the true center position for your 'bot’s head by setting these two constants at the top of the code. Unfortunately, I’m a blithering idiot and there have been times when instead of writing “hposition = hcenter” I end up transposing them “hcenter = hposition” causing wild and woolly things to happen.
What I would like to happen is that if I accidentally transpose the names, or make some other asinine mistake, the type-checker will catch it and tell me what an idiot I am rather than running one of Charlie’s servos hard against the stop, possibly breaking something.
So far, the only thing I have found is the “Finally” construct, as in:
vcenter: Finally = 74
whereupoon “vcenter” is hammered into the ground.
“Da’ bitch part” is that “Finally” only exists in Python 3.8 or later. Right now, (using RFR Buster 12/19), we’re sitting fat, dumb and happy at Python 3.7.3. - and I can’t even import it from __future__.
(I had to “escape” (\_\_) the two underscores on each side with backslashes, otherwise they were considered formatting characters.)
I’d really like to do something “standard” so that anyone with a GoPiGo can run my code.