Page 162 -
P. 162

nonstandard output


          Why not modify print  lol()?


           Recall your print_lol() function from Chapter 2, which takes any list (or
           list of lists) and displays it on screen, one line at a time. And nested lists can
           be indented, if necessary.
           This functionality sounds perfect! Here’s your code from the nester.py
           module (last seen at the end of Chapter 2):




















                                                                          This code currently displays your
                                                                          data on the screen.








          Amending this code to print to a disk file instead of the screen (known as
           standard output) should be relatively straightforward. You can then save your
           data in a more usable format.








                                        Standard Output The default place where your code writes its
                                        data when the “print()” BIF is used. This is typically the screen.

                                           In Python, standard output is referred to as “sys.stdout” and
                                             is importable from the Standard Library’s “sys” module.




           126    Chapter 4
   157   158   159   160   161   162   163   164   165   166   167