Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(0)  |  Derive(0)  |  Import(2)
Class decorator. You define __str__() and it is moved to
__unicode__() on Python 2.

Additionally, if you define __bytes__(), it becomes __str__() on
Python 2. If __bytes__() is not defined, __str__() executes
__unicode__() and encodes the result to utf-8.

            def implements_to_string(cls):
        '''Class decorator. You define __str__() and it is moved to
        __unicode__() on Python 2.

        Additionally, if you define __bytes__(), it becomes __str__() on
        Python 2. If __bytes__() is not defined, __str__() executes
        __unicode__() and encodes the result to utf-8.
        '''
        cls.__unicode__ = cls.__str__
        cls.__str__ = cls.__bytes__ if hasattr(cls, '__bytes__') \
            else lambda x: x.__unicode__().encode('utf-8')
        return cls
        


src/n/i/nine-0.3.3/nine/test_nine.py   nine(Download)
    def test_import(self):
        from nine import (IS_PYTHON2, str, basestring, native_str,
            integer_types, class_types, range, range_list, reraise,
            iterkeys, itervalues, iteritems, map, zip, filter, input,
            implements_iterator, implements_to_string, implements_repr, nine,

src/n/i/nine-HEAD/nine/test_nine.py   nine(Download)
    def test_import(self):
        from nine import (IS_PYTHON2, str, basestring, native_str,
            integer_types, class_types, range, range_list, reraise,
            iterkeys, itervalues, iteritems, map, zip, filter, input,
            implements_iterator, implements_to_string, implements_repr, nine,