|
|
|
|
|
by fennecfoxen
1679 days ago
|
|
Your expectation does not match the best practices that language designers have converged on in this day and age. No one can keep up with all the variables outside a given function, and it’s way to easy to cause confusing, untraceable side effects. In almost every language, variables introduced in methods like this will be lexically scoped when the contrary is not otherwise indicated. (Some of the older languages do differ, and usually best practices in those languages include running linters that yell at you to use explicit scopes.) |
|
I can see the point a bit of added safety of basically defaulting to a constant when declaring global variables, although since I use older languages (but not python), I have not run into that. I do find it humorous that the global variable is semi-protected in python, while the variable type is not.