On Sun, Oct 3, 2021, 1:46 AM Christopher Barker

> The if __name__ block is only required for a Python file to be both a
> module and a script.
> That’s actually a pretty uncommon thing— if it’s a module to be imported
> by other modules, then it probably should be part of a package, and if the
> functionality needs to be made available as a script, there can be another
> module just for that.
>

I think all the slightly different boilerplate forms suggested are
needless. So on the main topic, -1.

But as a note, I usually put a __name__=='__main__' block at the foot of my
library code.

The few functions in this particular file presumably do something useful,
and hopefully composable. Why not allow command-line users to do just that
one thing by itself? Sure, the predominant use is within a library, but
being able to try out this functionality usually helps my development, and
is sometimes useful to have around and composable in bash.
_______________________________________________
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/6XGPJH57YY4N2AC6P4VY67VNYPINZKQD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to