[Python-ideas] breaking out of module execution

M.-A. Lemburg mal at egenix.com
Wed Apr 25 17:09:16 CEST 2012


Arnaud Delobelle wrote:
> (sent from my phone)
> On Apr 25, 2012 3:01 PM, "M.-A. Lemburg" <mal at egenix.com> 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.
> 
> OTOH the return statement becomes really hard to spot...

People don't appear to have a problem with this in long functions
or methods, so I'm not sure how well that argument qualifies.

The programmer can of course add an easy to spot comment where
the return is used. Just as question of programming style.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 25 2012)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
2012-04-28: PythonCamp 2012, Cologne, Germany               3 days to go
2012-04-25: Released eGenix mx Base 3.2.4         http://egenix.com/go27

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/



More information about the Python-ideas mailing list