If I write code like this, What will happen? Will the file object close automatically?
# Do something before
# Make the value = 1 when the number in file.
for line in open('input_file.txt', 'r'):
index_list[int(line)] = 1
# Do something later
Or I have to write code like this?
with open('xxx.txt', 'r') as f:
# Do something