side-effects

Why are global variables evil?

淺唱寂寞╮ 提交于 2019-11-25 21:37:30
问题 I was trying to find a good source that explains why the use of global is considered to be bad practice in python (and in programming in general). Can somebody point me to one or explain here? 回答1: This has nothing to do with Python; global variables are bad in any programming language. However, global constants are not conceptually the same as global variables ; global constants are perfectly harmless. It's just that in Python there is no enforced difference, only by convention are CONSTANTS