Q:

Using if/else statement and exit function in Python

The two cases below describe my dilemma. I would like to understand when the code is more stable.
Case A
from sys import argv

a = float( argv[1] )
b = float( argv[2] )

if a == 0.:
    exit(1)
else:          
    print b / a

exit( 0 )

Case B
from sys import argv

a = float( argv[1] )
b = float( argv[2] )

if a == 0.:
    exit(1)

print b / a

exit( 0 )

A:

Both methods offer the same stability because, in essence, they do the same thing.
However, the first one uses else unnecessarily.  If the code hits the exit(1) line, it immediately exits the script.  Meaning, else doesn't contribute anything positive (such as flow-control).  In fact, all it does is take up a line and cause unnecessary indenting.
So, if you are wondering which method to choose, I'd say to use the second.  It is cleaner and uses less syntax to do the same job.

Also, since exiting a script usually means something unusual and bad happened, using just the if without the else makes it somewhat clearer that you are protecting against a freak occurrence.

