[Python-ideas] breaking out of module execution
ronaldoussoren at mac.com
Wed Apr 25 14:37:56 CEST 2012
On 25 Apr, 2012, at 14:11, 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?
Harder to understand code is one disadvantage. The "return" that ends execution can easily be hidden in a list of definitions, such as
... some definitions ...
if sys.platform != 'win32': return
... more definitions for win32 specific functionality ...
That's easy to read with a 10 line module, but not when the module gets significantly larger.
Also, why use the proposed module-scope return instead of an if-statement with nested definitions, this works just fine:
: def foo(): pass
: if sys.platform == 'linux':
: def linux_bar(): pass
> Python-ideas mailing list
> Python-ideas at python.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4788 bytes
Desc: not available
More information about the Python-ideas