my cent:
I think it's most often a bad practice (whereas it's convenient) to mix "executable" and "importable" code.
Providing an easier way to do it, may encourage a bad practice.

I would prefer a solution which encourage separation of "executable" and "importable" code.




2013/11/26 Andrew Barnert <abarnert@yahoo.com>
On Nov 26, 2013, at 8:34, Alan Cristhian Ruiz <alan.cristh@gmail.com> wrote:

> I think the need to change * if __ name__ == "__main__": * is capricious and obsessive. The current rule is better than anything that has been suggested so far. I never had any problems with the * if __ name__ == "__main__": *. Also in python there are other things much more difficult to learn and use, such as metaclasses.

Although I agree with your main point, I don't think that's a very good argument.

__main__ is something novices have to learn early and use in code regularly; metaclasses are something only experienced developers use, and not that often (and that's even if you count using stdlib metaclasses to, e.g., create ABCs, which doesn't really require you to understand how they work). It's perfectly reasonable for an "expert" feature to be more difficult to learn than a novice feature.

Also, Python doesn't have a queue of improvements to be scheduled to a team of developers. Things get improved if someone is motivated enough to write the code and drive the idea to consensus and/or BDFL approval. So, improving this would have very little bearing on improving things you care about more.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas