[Python-ideas] breaking out of module execution
steve at pearwood.info
Wed Apr 25 14:30:32 CEST 2012
Mark Shannon wrote:
> Steven D'Aprano wrote:
>> 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:
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
- 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.
And to see the context:
More information about the Python-ideas