News for hackers. Stuff that matters.
Re:An exploration of why Python doesn't require a 'main' fun... by andybak on Tuesday July 21, 2020 @01:19PM (#23908755)
You only need the __main__ magic if you want a python file to be both a module and an executable script. This is a moderately advanced requirement. Beginners will tend to write scripts OR importable modules.
Re:An exploration of why Python doesn't require a 'main' fun... by geoelectric on Tuesday July 21, 2020 @05:13PM (#23911057)
For debugging-in-REPL purposes it's often very convenient to have it both ways. I was taught as a beginner to treat it as idiomatic boilerplate for that reason--no harm in having it, and there when you need it. Then you can just import your script and ad hoc test your functions.

It's a good technique prior to introducing formal unit testing (and even then, supplemental ad hoc has advantages).