Skip to content

Instantly share code, notes, and snippets.

@twpayne
Created October 20, 2012 20:51
Show Gist options
  • Save twpayne/3924761 to your computer and use it in GitHub Desktop.
Save twpayne/3924761 to your computer and use it in GitHub Desktop.
simplerepr
def simplerepr(obj):
keys = sorted(key for key in obj.__dict__.keys() if not key.startswith('_'))
attrs = ''.join(' %s=%r' % (key, obj.__dict__[key]) for key in keys)
return '<%s%s>' % (obj.__class__.__name__, attrs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment