I kinda like it. Definitely +0.0, maybe +0.5.
On Thu, Nov 12, 2020 at 2:46 PM Matt Wozniski firstname.lastname@example.org wrote:
It would behave as though
__main__ = (__name__ == "__main__")
is executed in each module's namespace before executing it.
Some other commenters say they rarely dual-use modules as scripts. I do this quite often myself. There's some little functionality that is useful from the command-line, but some supporting functions within it, or some more nuanced version of calling those arguments is also useful in larger projects. I know there are other ways to achieve that purpose, but for quick-and-easy, the __name__=='__main__' is something I do often.
I don't think this would break anything. Yes, the slightly more verbose version would need to be maintained forever. But the semantics of __main__ being implicitly defined when scripts are run is easy to explain.