def get_repr(obj, constructor=False, **attrs):
 cls = qualname(obj.__class__)
 parts = []
 items = sorted(attrs.items())
 for (name, val) in items:
  parts.append('{}={!r}'.format(name, val))
 if constructor:
  return '{}({})'.format(cls, ', '.join(parts))
 elif parts:
  return '<{} {}>'.format(cls, ' '.join(parts))
 else:
  return '<{}>'.format(cls)

def get_repr ( obj , constructor = False , ** attrs ) : cls = qualname ( obj . __class__ ) parts = [ ] items = sorted ( attrs . items ( ) ) for ( name , val ) in items : parts . append ( '{}={!r}' . format ( name , val ) ) if constructor : return '{}({})' . format ( cls , ', ' . join ( parts ) ) elif parts : return '<{} {}>' . format ( cls , ' ' . join ( parts ) ) else : return '<{}>' . format ( cls )
get a suitable __repr__ string for an object .