It's really a comprehension vs brevity thing, and a matter of personal 
style.  Removing the else gives shorter code, which is *usually* more 
clear.  But without the *else*, you have to *infer* its virtual presence, 
and that interferes with comprehension.  I'm not consistent about this, 
myself.  But functionally, sure, both forms are the same.

On Wednesday, April 1, 2020 at 9:52:27 AM UTC-4, vitalije wrote:
>
> I doubt that. A few days ago I've run pylint and it reported some 
> complains about non necessary else after break, or after return. My first 
> reaction was just like yours, but then I looked more closely and those 
> complains were correct.
>
> while True:
>     ... # some code here
>     if condition:
>          break
>     else:
>          do_something_else_here()
>
> # or 
> def f():
>     # some code ...
>     if condition:
>         return result_a
>     else:
>         do_other_thing()
>         # ... 
>         return result_b
>
>
>  In both cases, meaning of the program is the same as if the else block 
> was unindented and else removed.
>
> Vitalije
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/2b0a9209-30fc-413a-be35-a152c30ebdd1%40googlegroups.com.

Reply via email to