A good practice when reading from a file in Python

Post date: Sep 20, 2016 5:04:11 PM

Good practice:

import csv     fileName = "myfile.csv"  try:     with open(fileName, 'rb') as f:

reader = csv.reader(f) for row in reader: #do stuff here pass except IOError: print "Could not read file:", fileName

From this URL.