You don't need to declare the variable, Python uses function scope. A variable declared in the try
block will automatically be available afterwards if the assignment was executed without any exception:
Case 1: No Exception
try:
inputFile = open( sys.argv[0] )
except IOError as e:
print "ERROR: Could not open " + sys.argv[0]
# inputFile is opened file
Case 2: Exception
try:
inputFile = open( sys.argv[0] )
except IOError as e:
print "ERROR: Could not open " + sys.argv[0]
# inputFile is not defined