(instance, spec=None)
| 1 | def makeReprStr(instance, spec=None): |
| 2 | arg_list = [] |
| 3 | for field in spec or (): |
| 4 | if isinstance(field, str): |
| 5 | repr_name, attr_name = field, field |
| 6 | else: |
| 7 | repr_name, attr_name = field |
| 8 | attr_val = getattr(instance, attr_name, 'N/A') |
| 9 | arg_list.append('{}={}'.format(repr_name, attr_val)) |
| 10 | return '<{}({})>'.format(type(instance).__name__, ', '.join(arg_list)) |