Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use all attributes if no list or format string is specified #2

Open
languitar opened this issue Feb 2, 2017 · 0 comments
Open

Use all attributes if no list or format string is specified #2

languitar opened this issue Feb 2, 2017 · 0 comments

Comments

@languitar
Copy link

languitar commented Feb 2, 2017

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) + ')'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant