On 2 Oct 2021, at 18:17, Paul Bryan <pbryan@anode.ca> wrote:
Thanks for finding that.
While I don't feel strongly one way or the other, I do think the discussion is worthwhile.
As I understand, the arguments for: - let's get rid of boilerplate, that many (esp. beginners) may not understand - you could add command line arguments and return values in a more natural way
As I understand, the arguments against: - it's just 2 lines of code; this isn't a big problem being solved - boilerplate serves to teach a fundamental concept about the loading and execution of Python modules - there may not be a clean way to maintain compatibility with previous versions of Python
It is 2 lines of code that a beginner does not need to write at all. I see a lot of short scripts that do not bother with the main function at all, they just put all the code at module level. And why not? Indeed I do not bother for short scripts either. Once someone is doing more complex scripting then the benifits of the 2 lines and main function become something worth understanding and using. Namely it allows importing the code and testing it. Barry