2

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?

4
  • Global declarations are in individual functions, not files. Commented Oct 18, 2020 at 7:58
  • 1
    But in general, nothing in one file affects any other file, unless you import one of them into the other. Commented Oct 18, 2020 at 7:58
  • 1
    A good explanation here: stackoverflow.com/a/3400652/10498119 Commented Oct 18, 2020 at 8:00
  • tysm @SubirVerma Commented Oct 18, 2020 at 8:07

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.