I kinda like it.  Definitely +0.0, maybe +0.5.

On Thu, Nov 12, 2020 at 2:46 PM Matt Wozniski <godlyg...@gmail.com> wrote:

>     if __main__:
>
> 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.



-- 
The dead increasingly dominate and strangle both the living and the
not-yet born.  Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/SQBKU5GLSN2GK7LKYRJDIXMRN3Q7AXH7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to