News for hackers. Stuff that matters.
Re:An exploration of why Python doesn't require a 'main' fun... by zelphirkalt on Tuesday July 21, 2020 @12:20PM (#23908130)
And still I do write a main procedure in Python usually, which is called from that if __name__ == "__main__" thing. It is convenient to leave the top level asap and begin as quickly as possible to use procedures/function, getting out of the area, where one can accidentally change global variables, without noticing (in procedures you would have to write global as a keyword and would hopefully then notice you are doing something possibly dangerous).
Re:An exploration of why Python doesn't require a 'main' fun... by quietbritishjim on Tuesday July 21, 2020 @12:46PM (#23908409)
Absolutely. But on the other hand, it's still very useful that Python does work like this: it's nice to be able to directly do things at the top level (e.g. setting up "constants" with a little computation, conditionally importing modules or importing fallbacks, etc.). As the article says, it's also an extremely clean way of defining what gets run in what order during startup.
Re:An exploration of why Python doesn't require a 'main' fun... by tcbasche on Tuesday July 21, 2020 @11:29PM (#23913641)
Pycharm also puts a handy play button on it too, which is literally the only reason I do it. (sheer laziness)