MCPcopy Index your code
hub / github.com/dabeaz-course/python-mastery / print_table

Function print_table

Solutions/8_6/tableformat.py:4–11  ·  view source on GitHub ↗
(records, fields, formatter)

Source from the content-addressed store, hash-verified

2from abc import ABC, abstractmethod
3
4def print_table(records, fields, formatter):
5 if not isinstance(formatter, TableFormatter):
6 raise RuntimeError('Expected a TableFormatter')
7
8 formatter.headings(fields)
9 for r in records:
10 rowdata = [getattr(r, fieldname) for fieldname in fields]
11 formatter.row(rowdata)
12
13class TableFormatter(ABC):
14 @abstractmethod

Callers

nothing calls this directly

Calls 2

headingsMethod · 0.45
rowMethod · 0.45

Tested by

no test coverage detected