autorepr icon indicating copy to clipboard operation
autorepr copied to clipboard

Use all attributes if no list or format string is specified

Open languitar opened this issue 8 years ago • 0 comments

Would be nice if there was a completely automatic method which prints all attributes of a class in case the manual list or format string is not specified.

I have been using something like this before:

name = self.__class__.__name__ + '('
attrs = ['{}={}'.format(k, v) for k, v in vars(self).items()]
return name + ', '.join(attrs) + ')'

languitar avatar Feb 02 '17 13:02 languitar