osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How should we use global variables correctly?


I can 'feel' that global variables are evil. I also read lots of articles
proves that (http://wiki.c2.com/?GlobalVariablesAreBad). However, I found
CPython Lib use quite a lot of `global` keyword. So how should we use
`global` keyword correctly? IIUC, it's fine that we use `global` keyword
inside the Lib since most of the time the user just import the lib and call
the API. In any other situation, we should avoid using it. Am I right?