Skip to content

Instantly share code, notes, and snippets.

@KristofferHebert
KristofferHebert / tryexcept.py
Last active March 17, 2018 23:08
08 python with Kristoffer Hebert
def read_file(filename):
try:
file = open(filename, 'r')
print 'Reading contents of', filename
return file.read()
except IOError as error:
print '[IOERROR]', error
except TypeError as error:
print '[TYPE ERROR]', error
except:
Moved to: http://github.com/gf3/dotfiles/blob/master/bash_prompt