Overhaul module-related commands
This commit is contained in:
10
utils/repr.py
Normal file
10
utils/repr.py
Normal file
@@ -0,0 +1,10 @@
|
||||
def makeReprStr(instance, spec=None):
|
||||
arg_list = []
|
||||
for field in spec or ():
|
||||
if isinstance(field, str):
|
||||
repr_name, attr_name = field, field
|
||||
else:
|
||||
repr_name, attr_name = field
|
||||
attr_val = getattr(instance, attr_name, 'N/A')
|
||||
arg_list.append('{}={}'.format(repr_name, attr_val))
|
||||
return '<{}({})>'.format(type(instance).__name__, ', '.join(arg_list))
|
||||
Reference in New Issue
Block a user