How should we use global variables correctly?
Richard Damon
Richard at Damon-Family.org
Thu Aug 22 21:05:43 EDT 2019
More information about the Python-list mailing list
Thu Aug 22 21:05:43 EDT 2019
- Previous message (by thread): How should we use global variables correctly?
- Next message (by thread): How should we use global variables correctly?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 8/22/19 12:00 PM, Windson Yang wrote: > 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? It should be noted that the Python 'global' is much more like the C/C++ file scoped 'static' which is less bad that fully global variables (the extern variable). -- Richard Damon
- Previous message (by thread): How should we use global variables correctly?
- Next message (by thread): How should we use global variables correctly?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list