#! /usr/local/bin/python import sys try: fi = open('sample_+_file', 'r') except IOError: print 'Can\'t open file for reading.' sys.exit(0)