Skip to content

Instantly share code, notes, and snippets.

@sposterkil
Created September 3, 2013 05:03
Show Gist options
  • Save sposterkil/6419868 to your computer and use it in GitHub Desktop.
Save sposterkil/6419868 to your computer and use it in GitHub Desktop.
My handling of exceptions and sys.exit()
def __init__(self, filename, slice_length):
try:
self.file = open(filename, 'r')
self.slice_length = int(slice_length)
except IOError, e:
print "No such file:", sys.argv[1]
sys.exit()
except ValueError, e:
print "\"%s\" isn't a number." % sys.argv[2]
print "Usage: Segmentor.py <file> <slice length>"
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment