Print a nicely formated table from a list of (name, shares, price, change) tuples.
(reportdata)
| 29 | return rows |
| 30 | |
| 31 | def print_report(reportdata): |
| 32 | ''' |
| 33 | Print a nicely formated table from a list of (name, shares, price, change) tuples. |
| 34 | ''' |
| 35 | headers = ('Name','Shares','Price','Change') |
| 36 | print('%10s %10s %10s %10s' % headers) |
| 37 | print(('-'*10 + ' ')*len(headers)) |
| 38 | for row in reportdata: |
| 39 | print('%10s %10d %10.2f %10.2f' % row) |
| 40 | |
| 41 | def portfolio_report(portfoliofile,pricefile): |
| 42 | ''' |