On Sat, Oct 2, 2021 at 2:01 PM Jonathan Crall <erotemic@gmail.com> wrote:
>
> @Steven D'Aprano Yes my original post is somewhat pithy and has some harsh words for decorators. Like many I have some opinions about code. Don't take them too seriously if they disagree with your experience, but I do hold my opinions for reasons, and I will explain some of them, but I don't want to derail my first python ideas proposal that has gotten some semblance of a positive reception.
>
> So I will quickly explain my terse statements in a more professional manner. And I will note again, these are opinions.
>
> * Avoid global variables, they make state difficult to reason about. Plenty of opinions have been written about this.
>
> * Code runs faster when it's in a function then when it is in a global scope. I don't have the reference on hand, but I can get it if anyone's interested. Python is a scripting language, but it's used heavily in production, It's nice if the efficient way of doing something is natural, intuitive, and easy.
>
> It's true that it's just a two-line pattern, and not all simplifications of two line patterns make it into the python standard. But this is an extremely common two line pattern. One that's often written less efficiently than it could be. If you already wrote the if statement for name, a new programmer is not incentivized to write a separate main function and then call it, it would be simpler if there was some construct that just declared this is the main function, and then the code inside the function is executed.
>
But it's ONLY necessary when a single Python file is used as both a
script and a module. Bear that in mind.
ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@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/B3RDNS6HB5UIPIGE5E2DEWL5JPC63W24/
Code of Conduct: http://python.org/psf/codeofconduct/