What is the point of
with open('grades.csv', 'r') as csvfile
in this code ????
import csv
with open('grades.csv', 'r') as csvfile:
grades_reader = csv.reader(csvfile, delimiter=',')
row_num = 1
for row in grades_reader:
print('Row #{}:'.format(row_num), row)
row_num += 1
?? becuase when I rewrite the code again as:
import csv
grades_reader=open('grades.csv', 'r')
row_num = 1
for row in grades_reader:
print('Row #{}:'.format(row_num), row)
row_num += 1
I get the same result but without the output being a list. So is it safe to assume that with command will turn it to a list when read?