suppose there is a variable "age" in 1.py and it is declared global inside 1.py. will the same variable "age" also be automatically declared as global in 2.py, and any other subsequent python files in the same directory?
-
Global declarations are in individual functions, not files.Barmar– Barmar2020-10-18 07:58:05 +00:00Commented Oct 18, 2020 at 7:58
-
1But in general, nothing in one file affects any other file, unless you import one of them into the other.Barmar– Barmar2020-10-18 07:58:57 +00:00Commented Oct 18, 2020 at 7:58
-
1A good explanation here: stackoverflow.com/a/3400652/10498119Subir Verma– Subir Verma2020-10-18 08:00:17 +00:00Commented Oct 18, 2020 at 8:00
-
tysm @SubirVermacheemse– cheemse2020-10-18 08:07:48 +00:00Commented Oct 18, 2020 at 8:07
Add a comment
|