Constants: are they there somewhere?

coding-style

#1

Some of the GM libraries use constants; others don’t. That is fine, though of course it would be nice if we had constants for things like checkbox choices values (“on” and “off”), among other things. This way we would eliminate typo bugs (which, in python, can sometimes be tricky to debug) and would ensure that it is easy to update code if the convention changes.

Are they already there, somewhere? Does anyone know? If not, I could start putting them in as I use them for my module. Would people say they belong to choices.py, perhaps? Or we could have a separate file for constants that are used across libraries (such as “yes”, “on”, “off” and I am sure there are other things).


#2

I would think common, broadly useful constants belong in a separate file. Putting them in with some other code just increases the chance of inadvertently creating a mutual dependency down the road.


#3

Agreed; plus, nobody will find them there…
I will create a file constants.py and will start with putting things like “on” and “off” there :).


#4

FWIW, PEP-8 naming conventions are here: https://www.python.org/dev/peps/pep-0008/#constants