Just to be clear, I'm currently working in a Java shop where the code-styles are to use all caps for constants, enums, and class-level variables. Most classes in our code base declare a class-level "LOG" or "LOGGER" object. I've found that completely unnecessary. A simple "log" works just fine. I've never been tempted to write over it. It would be impossible in Java anyway since the guidelines are to declare everything "final" (yes... shoot me) anyway. I helped one of the higher-ups in the company write a Python script and he found the lack of straight-jacket harnesses extremely distressing. How could you write code without "final"? or "private"? or type checking?! You have to use consistent white space?!?!
It's all Stockholm syndrome.
The whole point of the all-caps globals is to tell you a lot about what they are.
A lot? The only thing it canonically tells you is to not modify it which is my default assumption with any variable I didn't declare myself and also impossible to do in the case of enums.
I will often use a module-level constant
for a file or path name; within the module, it is deliberately treated
as a constant, but if you import the module somewhere else, you could
reassign it before calling any functions in the module, and they'll
all use the changed path.
Do you communicate that API through the variable name alone? How so? I would assume any module-level variables are not to be modified unless there was documentation stating otherwise. You really don't need a obnoxious shouty convention to tell people not to change things.
It's up to you whether you actually use the all-caps convention in
your own code or not, but IMO it is an extremely useful convention to
have in the toolbox, and should be kept.
My boss would say:
It's up to you whether you actually use final in
your own code or not, but IMO it is an extremely useful tool to
have in the toolbox, and should be kept. (and also you have to use it because it's in the style guide)