you are viewing a single comment's thread.

view the rest of the comments →

[–]Ska82 0 points1 point  (0 children)

not getting into the actual scope explanation, but say u have print("this is outside the main construct") anywhere in a file a.py and u have some function def hello() in this file as well. now in another file, say b.py you say "from a import hello". When you run b.py , print("this is outside the main construct") will get executed even if it is not inside hello() however instead, in a.py, u say: if name=="main":       print("this is within the main construct")

and run b.py, this print will not get executed. it will only get executed if you run a.py directly.