On Wed, May 26, 2021 at 5:26 PM Shreyan Avigyan email@example.com wrote:
Reply to Chris:
There are two things I want to say about constants :-
- Global-Local Constants - The ALL_CAPS convention variables should become constant.
- Class member constants - Constants should be used only for avoiding from being overridden. It should not be used as "We have a class. Use constants.". Sometimes if someone changes a critical value especially in Python a dynamically typed language it can have bad effects. Suppose we have a Windows and we go to registry editor and delete keys and set different values and then Windows won't boot up the next time. That's why class member constants is necessary.
I don't understand this mentality. Firstly, Windows *does* have a registry editor. You can indeed break things. Windows won't stop you. Secondly, CPython comes with the ctypes module that allows you to *change the values of literals*. I'm not kidding. You can actually make it so that the integer 42 actually behaves as if it's 28. Do we really need to stop people from doing things because they're dangerous?
There are many arguments in favour of constants, but this one strikes me as particularly weak.