[Python-ideas] breaking out of module execution
g.brandl at gmx.net
Wed Apr 25 21:37:24 CEST 2012
On 25.04.2012 16:00, M.-A. Lemburg wrote:
> Ronald Oussoren wrote:
>> 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
> Because this only works reasonably if you have a few lines of code
> to indent. As soon as you have hundreds of lines, this becomes
> both unreadable and difficult to edit.
So you don't have any classes that span hundreds of lines? I don't
see how this is different in terms of editing difficulty.
As for readability, at least you can see from the indentation that
there's something special about the module code in question. You
don't see that if there's a "return" scattered somewhere.
PS: I don't buy the "it's no problem with functions" argument. Even
though I'm certainly guilty of writing 100+ line functions, I find them
quite ungraspable (is that a word?) and usually try to limit functions
and methods to a screenful.
More information about the Python-ideas