def repr_wrapper(klass):
 if six.PY2:
  if ('__repr__' not in klass.__dict__):
   raise ValueError(("@repr_wrapper cannot be applied to %s because it doesn't define __repr__()." % klass.__name__))
  klass._repr = klass.__repr__
  klass.__repr__ = (lambda self: encodeutils.safe_encode(self._repr()))
 return klass

def repr_wrapper ( klass ) : if six . PY2 : if ( '__repr__' not in klass . __dict__ ) : raise ValueError ( ( "@repr_wrapper cannot be applied to %s because it doesn't define __repr__()." % klass . __name__ ) ) klass . _repr = klass . __repr__ klass . __repr__ = ( lambda self : encodeutils . safe_encode ( self . _repr ( ) ) ) return klass
a decorator that defines __repr__ method under python 2 .