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

Function print_table

Solutions/4_10/tableformat.py:73–80  ·  view source on GitHub ↗

Make a nicely formatted table from a list of objects and attribute names.

(objects, columns, formatter)

Source from the content-addressed store, hash-verified

71 raise FormatError(f'Unknown table format {name}')
72
73def print_table(objects, columns, formatter):
74 '''
75 Make a nicely formatted table from a list of objects and attribute names.
76 '''
77 formatter.headings(columns)
78 for obj in objects:
79 rowdata = [ str(getattr(obj, name)) for name in columns ]
80 formatter.row(rowdata)
81

Callers

nothing calls this directly

Calls 2

headingsMethod · 0.45
rowMethod · 0.45

Tested by

no test coverage detected