Assignment of global variables in a script.

"Popov, Dmitry Yu via Python-list" <[email protected]>
Newsgroups gmane.comp.python.general
Message-ID <DM8PR09MB63608BFB36AE0CC69C59E30DDB41A@DM8PR09MB6360.namprd09.prod.outlook.com>
Dear Sirs.

I found the following sentence in the Python documentation: "The statements executed by the top-level invocation of the interpreter, either read from a script file or interactively, are considered part of a module called __main__<https://docs.python.org/3.11/library/__main__.html#module-__main__>, so they have their own global namespace."

In other words, global assignments of variables placed directly in a module's name space are also "statements executed by the top-level invocation of the interpreter", if the module is executed as a script.

Is it stable at all to assign global variables directly in a module which runs as a script? Speaking practically, I have not observed any problem so far.

Regards,
Dmitry Popov
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.