Single line if statement with a continue

Thomas Passin list1 at tompassin.net
Thu Dec 15 14:56:03 EST 2022


On 12/15/2022 3:58 AM, Chris Green wrote:
> Thomas Passin <list1 at tompassin.net> wrote:
>>                     I personally tend to use
>>
>> if test: return
>>
>> even inside larger blocks.
> 
> I always try to avoid multiple returns from functions/methods, as soon
> as things get complex it's all to easy to miss clean-up etc.
> 
> "No multiple returns" is often found in programming guidelines.

Yes, or alternatively, "If any branch uses a return, they all should."




More information about the Python-list mailing list