Given an object `x`, call `str(x)` and format the returned string so that it is numchars long, padding with trailing spaces or truncating with ellipses as necessary
(x, numchars: int)
| 39 | |
| 40 | |
| 41 | def pretty_print(x, numchars: int): |
| 42 | """Given an object `x`, call `str(x)` and format the returned string so |
| 43 | that it is numchars long, padding with trailing spaces or truncating with |
| 44 | ellipses as necessary |
| 45 | """ |
| 46 | s = maybe_truncate(x, numchars) |
| 47 | return s + " " * max(numchars - len(s), 0) |
| 48 | |
| 49 | |
| 50 | def maybe_truncate(obj, maxlen=500): |
no test coverage detected
searching dependent graphs…