Skip to content

Instantly share code, notes, and snippets.

Created June 11, 2012 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/2913468 to your computer and use it in GitHub Desktop.
Save anonymous/2913468 to your computer and use it in GitHub Desktop.
import sys
try:
f = open('myfile.txt')
s = f.readline()
i = int(s.strip())
except IOError as e:
print "I/O error({0}): {1}".format(e.errno, e.strerror)
except ValueError:
print "Could not convert data to an integer."
except:
print "Unexpected error:", sys.exc_info()[0]
raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment