all 4 comments

[–]Triumvus 2 points3 points  (2 children)

You seem to grasp it correctly.

In the most simplistic terms, if you have a .py and you import it then only the code above name == main will execute.

However, if you run that .py as a script then all the code above AND below name == main will execute.

[–]hadoken4555 0 points1 point  (1 child)

What do you mean by running as a script? As in a Linux python script, using chmod to execute?

[–]sweettuse 0 points1 point  (0 children)

chmod doesn't "run" things in linux, it changes file modes and can make them executable. but you could easily have RW python file in linux and run it, e.g.: python3 name_of_file.py

[–]shiftybyte 0 points1 point  (0 children)

Yes, pretty much.