On Thursday, June 6, 2019 at 12:10:58 PM UTC-5, Edward K. Ream wrote:

> This removes all no-else-return complaints from pylint.

My first reaction to this check was "huh?"  But the more I see the changes 
the better I like them:

- Flow of control is often easier to understand.
- The new style often results in less indented code and fewer "else" 
statements.

While making all these changes, I fixed some howlers:

if condition:
  return True
else:
  return False

Should be:

return condition

Similarly:

if condition:
  return val1
else
  return val2

can be replaced (if condition isn't too long) by:

return val1 if condition else val2

And worse:

if not condition:
  return val1
else
  return val2

should be:

return val2 if condition else val1

All such replacements are opportunities for blunders, so one must take care!

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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/8bb5d6ac-a59a-44ff-a337-5ab6ff15b74d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to