On Sat, Oct 02, 2021 at 10:17:12AM -0700, Paul Bryan wrote:

> As I understand, the arguments for:
> - let's get rid of boilerplate, that many (esp. beginners) may not
> understand

The proposal doesn't get rid of boilerplate, it just changes it from one 
form to another.

The current idiom uses an explicit if test `if __name__ == "__main__"` 
which would be replaced by some other boilerplate. Some of the proposals 
have included:

    def main():
        ...

    __main__(main)


or 

    import sys
    def main():
        ...

    sys.run_main()

or just an implicit magic dunder function:

    def __main__():
        ...

Whichever proposal we go with, its still boilerplate.

Boilerplate is not necessarily bad. Boilerplate code is predictable, 
standardized code that can be easily reused with little or no variation. 
Predictable and standardized is another way of saying *idiomatic*, which 
is a good thing.

Boilerplate is only bad when you have to write a lot of boilerplate to 
get to the small amount of code that actually solves your problem. 
Another name for that is scaffolding. Python (unlike some languages) 
rarely has a problem with excessively verbose scaffolding, and a one or 
two line idiomatic snippet to run code as a script is hardly excessively 
verbose.


-- 
Steve
_______________________________________________
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/H2U3NZXZS763EG4DAVSAAMY4YI2VDA42/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to