Say I have a txt file,
fantasy,12/03/2014
sci-fi,13/04/2014
history,03/04/2014
And I use the following code to convert it into a python list
def load_list(filename):
my_file = open(filename, "rU")
my_list = []
for line in my_file:
a,b = line.rstrip("\n").split(",")
my_list.append((as_datetime(b),a))
my_file.close()
return my_list
which outputs
[(datetime.datetime(2014, 3, 12, 0, 0), 'fantasy'), (datetime.datetime(2014, 4, 3, 0,
0), 'history'), (datetime.datetime(2014, 4, 12, 0, 0), 'sci-fi')].
I can assume that the list will be further modified (appended and removed) while being used. My question is, how can I implement a function to export the list as a txt file that followed the formatting of the original file?