osx-config-check
osx-config-check copied to clipboard
Why use const?
I have never seen const.py used before in Python. I am curious as to why you are using this instead of say globals or a config file?
Genuinely curious, this is not meant as criticism.
Globals or a config file would work fine. One thing I like about this const class is that it's actually immutable, and can't be reassigned in some underhanded way, making secure code review easier.
http://code.activestate.com/recipes/65207-constants-in-python/?in=user-97991
What do you think -- does it make the code better or worse?
Personally it seems pretty un-pythonic (which is a slippery term) and unnecessarily complicates this code. I don't think there is any danger in having a mutable object for the config. The code that you linked is from a different era of python.
If immutable-ness is still important look into a namedtuple to store config values. That said I would really recommend the configparser module. It will separate your config variables out into a file and integrate well into turning this into an app that takes arguments on the command line.
My 2¢
I see. Thanks for the feedback! I will mull it over a bit.
I've used configparser before, but will probably put off using it since it takes a lot more development time than to read from sys.argv, and there's only demand for a single command-line arg so far.