autorepr
autorepr copied to clipboard
Use all attributes if no list or format string is specified
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) + ')'