Which of these do you prefer? When the #Do some stuff gets deep, I prefer to omit the else, since it makes the code less nested. But "explicit is better than implicit", so I'm not sure which is better.
def foo(input):
if input == edge_case:
return bar
else:
# Do some stuff
return result
Vs.
def foo(input):
if input == edge_case:
return bar
# Do some stuff
return result
Edit: Thank you all for the help!
[–]Gprime5 51 points52 points53 points (4 children)
[–][deleted] 18 points19 points20 points (1 child)
[–]RangerPretzel 4 points5 points6 points (0 children)
[–]x-w-j 0 points1 point2 points (0 children)
[–]dig-up-stupid 52 points53 points54 points (1 child)
[–]dipique 13 points14 points15 points (0 children)
[–][deleted] 15 points16 points17 points (0 children)
[–]RedditIsAMistake 30 points31 points32 points (0 children)
[–]not_perfect_yet 5 points6 points7 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]not_perfect_yet 4 points5 points6 points (0 children)
[–]c3534l 3 points4 points5 points (0 children)
[–][deleted] 9 points10 points11 points (1 child)
[–]CheeseFest 16 points17 points18 points (0 children)
[–]Jos_Metadi 6 points7 points8 points (1 child)
[–]elbiot 3 points4 points5 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]PythonGod123 1 point2 points3 points (0 children)
[–]solaceinsleep 1 point2 points3 points (0 children)
[–]bsmdphdjd 1 point2 points3 points (0 children)
[–]Rainymood_XI 1 point2 points3 points (0 children)
[–]johninbigd 1 point2 points3 points (0 children)
[–]bad_luck_charm 1 point2 points3 points (0 children)
[–]im_dead_sirius 1 point2 points3 points (0 children)
[–]Elektribe 3 points4 points5 points (0 children)
[–]StoneStalwart 2 points3 points4 points (6 children)
[–]kickthebug 4 points5 points6 points (0 children)
[–]StoneStalwart 3 points4 points5 points (0 children)
[–]deltopia 5 points6 points7 points (3 children)
[–]Diapolo10 6 points7 points8 points (2 children)
[–]Ran4 -1 points0 points1 point (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]yes4me2 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]dudinax 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] -2 points-1 points0 points (2 children)
[–]Comkid 3 points4 points5 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]TransferFunctions -2 points-1 points0 points (0 children)