Page 149 -
P. 149

persistence



                        Test Drive




                Perform the edits to your code to replace your two print() calls with your new file I/O code. Then, run your
                program to confirm that the data files are created:

                                                                                   Before your program runs,
                                                                                   there are no data files in
                                                                                   your folder, just your code.



                                                                                             When you run
                                                                                             your code, this
                                                                                             is all you see,
                                                                                             what looks like
                                                                                              an “empty” IDLE
                                                                                              shell.
















                After your program
                runs, two new files are
                CREATED in your folder.




           That code worked, too. You’ve created two data files, each holding the data
           from each of your lists. Go ahead and open these files in your favorite editor
           to confirm that they contain the data you expect.







                                    Consider the following carefully: what happens to
                                    your data files if the second call to print() in
                                    your code causes an IOError?


                                                                                      you are here 4    113
   144   145   146   147   148   149   150   151   152   153   154