On Wed, Apr 1, 2020 at 8:52 AM vitalije <[email protected]> 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.
>

The test is valid in the cases you give. However, the test is invalid if
the break is within an 'if' statement. It's a botch.

Edward

-- 
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/CAMF8tS2%3DrRVRL_8EqMonvj%3DC3GQUDONG%3DaT8TOek2qghUMBg9w%40mail.gmail.com.

Reply via email to