[Python-ideas] breaking out of module execution
Steven D'Aprano
steve at pearwood.info
Wed Apr 25 14:30:32 CEST 2012
Mark Shannon wrote:
> Steven D'Aprano wrote:
>
> [snip]
>
>> Unless you address the disadvantages and costs of top level return,
>> you won't convince me, and I doubt you will convince many others.
>>
>
> What costs?
Quoting from my post earlier today:
[quote]
Even if break at the module level is useful on rare occasions, I think the
usefulness is far outweighed by the costs:
- hard to use correctly, hence code using this feature risks being buggy
- encourages premature micro-optimization, or at least the illusion of
optimization
- encourages or requires duplicate code and copy-and-paste programming
- complicates the top-level program flow
Today, if you successfully import a module, you know that all the top-level
code in that module was executed. If this feature is added, you cannot be sure
what top-level code was reached unless you scan through all the code above it.
[end quote]
And to see the context:
http://mail.python.org/pipermail/python-ideas/2012-April/014897.html
--
Steven
More information about the Python-ideas
mailing list