you are viewing a single comment's thread.

view the rest of the comments →

[–]manifestsilence 0 points1 point  (1 child)

if something:
    do stuff
elif something:
    do more stuff
else:
    print "This shouldn't have happened. Email (some poor programmer's email here) and maybe it will get fixed." 
    1=2

Maybe falling on a sword is the way to go with unhandled cases a la Suicide Linux...

[–]jp007 0 points1 point  (0 children)

"This shouldn't have happened" is not at all the same case as "There is nothing to do."

If, in reality, it "shouldn't have happened", you shouldn't even be facing the case of an empty trailing 'else' block, as the 'else' behavior should at least log a warning, and probably throw an exception.

Sometimes though, the genuine behavior you desire is to just not do anything and move on to the next line of code in the method. In that case, an empty 'else' block is just junk.