← Back
Editing: newobject.cpython-38.pyc
U ,�] � @ s d Z G dd� de�ZdgZdS )u� An object subclass for Python 2 that gives new-style classes written in the style of Python 3 (with ``__next__`` and unicode-returning ``__str__`` methods) the appropriate Python 2-style ``next`` and ``__unicode__`` methods for compatible. Example use:: from builtins import object my_unicode_str = u'Unicode string: 孔子' class A(object): def __str__(self): return my_unicode_str a = A() print(str(a)) # On Python 2, these relations hold: assert unicode(a) == my_unicode_string assert str(a) == my_unicode_string.encode('utf-8') Another example:: from builtins import object class Upper(object): def __init__(self, iterable): self._iter = iter(iterable) def __next__(self): # note the Py3 interface return next(self._iter).upper() def __iter__(self): return self assert list(Upper('hello')) == list('HELLO') c @ s<