Created
September 3, 2013 05:03
-
-
Save sposterkil/6419868 to your computer and use it in GitHub Desktop.
My handling of exceptions and sys.exit()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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