On Fri, Oct 01, 2021 at 03:40:54PM -0400, Jonathan Crall wrote: > That would also make a lot of sense. That way has fewer characters without > sacrificing clarity, which is a +1 in my book. > > On Fri, Oct 1, 2021 at 3:38 PM Paul Bryan <pbr...@anode.ca> wrote: > > > How about the following? > > > > def __main__(): > > > > ...
+1000! This is very clean and natural. It fits nicely in the python naming model, because the double-dunder name is formally reserved. A nice bonus is that this scheme is very close to main() in C/C++/Java and other compiled languages, so users coming in from those languages will understand this without further explanation. (If this proposal were accepted, I think it'd make sense to introduce a __future__.main_function that'd enable this functionality as opt-in first, and only later as the default.) > > Behavior: > > > > 1. Load module as normal. > > 2. If __name__ is "__main__" or module is named in python -m, call > > __main__ function. Zbyszek _______________________________________________ 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/QLIPPYUEEY3ZLJRF7KYIEZIZXD2R4PKT/ Code of Conduct: http://python.org/psf/codeofconduct/