Skip to content

Instantly share code, notes, and snippets.

@jpic
Forked from anonymous/gist:2913468
Created June 12, 2012 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpic/2913541 to your computer and use it in GitHub Desktop.
Save jpic/2913541 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