(continued from previous page import sys import csv from abc import abcabstractmethod from pythonic import ring abstract class for table-format class tableformat(object)""abastract class "" print data to file or screen def __init__(selfout_file=none)if out_file =nonestdout is the location where python prints the output out_file sys stdout self out_file out_file @abstractmethod def heading(selfheader)must be implemented in child class pass @abstractmethod def row(selfrow_data)must be implemented in child class pass text format for table class textformat(tableformat)""text format for table "" option for modifying width def __init__(selfwidth= out_file=none)override init inherit parent init as well to save data in file super(__init__(out_fileself width width def heading(selfheader)print headers for in headerprint("{ :>{ } }format(hself width)end='file=self out_fileprint(file=self out_file def row(selfrow_data)print rows for in row_dataprint("{ :>{ } }format(rself width)end='file=self out_fileprint(file=self out_file csv format for table class csvformat(tableformat)""text format for table "" init will be inherited from parent to save data in file def heading(selfheader)print headers print(',join(header)file=self out_file def row(selfrow_data)print rows print(",join(row_data)file=self out_file(continues on next page advance inheritance