Skip to content

Instantly share code, notes, and snippets.

@pathunstrom
Last active February 8, 2018 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pathunstrom/d60748cfd7824e2c1552c00f57b25cc4 to your computer and use it in GitHub Desktop.
Save pathunstrom/d60748cfd7824e2c1552c00f57b25cc4 to your computer and use it in GitHub Desktop.
A very simple auto repr
from inspect import signature
class Example:
def __repr__(self):
val = lambda x: f"{x}={getattr(self, x)!r}"
parameters = ", ".join(val(param) for param in signature(type(self)).parameters)
return f"{type(self).__name__}({parameters})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment