def python_2_unicode_compatible(klass):
 if (not six.PY3):
  klass.__unicode__ = klass.__str__
  klass.__str__ = (lambda self: self.__unicode__().encode(u'utf-8'))
 return klass

def python_2_unicode_compatible ( klass ) : if ( not six . PY3 ) : klass . __unicode__ = klass . __str__ klass . __str__ = ( lambda self : self . __unicode__ ( ) . encode ( u'utf-8' ) ) return klass
a decorator that defines __unicode__ and __str__ methods under python 2 .