Jan-17-2018, 06:55 PM
Well, we also say that modules are good, and doing
There are obviously some cases (though not very many) where eval and globals make sense, just like there's some cases goto makes sense. This is not one of those cases, and I don't think most people will encounter them.
I do agree that immutable globals aren't that bad. The main issue I have with them, is that any part of your code can be reading/changing the values, so if something doesn't work as expected, it's incredibly difficult to hunt down why a variable has a certain value. In addition to that, one of the best things a fragment of code can be, is clear. If you can't immediately tell what a function is doing, because it's using values that are defined/modified *anywhere*, then that function is NOT clear.
from some_package import *
is bad, but that's the only way you CAN do things in C. Python is supposed to be better. Just because we can do things this way, doesn't mean that they should be done that way.There are obviously some cases (though not very many) where eval and globals make sense, just like there's some cases goto makes sense. This is not one of those cases, and I don't think most people will encounter them.
I do agree that immutable globals aren't that bad. The main issue I have with them, is that any part of your code can be reading/changing the values, so if something doesn't work as expected, it's incredibly difficult to hunt down why a variable has a certain value. In addition to that, one of the best things a fragment of code can be, is clear. If you can't immediately tell what a function is doing, because it's using values that are defined/modified *anywhere*, then that function is NOT clear.