Jeff Hall wrote:
I'm not sure about the first but as for the __reversed__ we had a
discussion yesterday and it was indeed added in 2.4 (oddly, my 2.5
documentation has this correct... )
2.4 doc:
reversed( seq)
Return a reverse iterator. seq must be an object which supports the
sequence protocol (the __len__() method and the __getitem__() method
with integer arguments starting at 0). New in version 2.4.
[no mention of __reversed__]
3.3.6 Additional methods for emulation of sequence types
[ditto]
However, I confirmed that __reversed__ is used by reverse()
class C:
def __reversed__(self): return 'abc'
c=C()
print(reversed(c))
>>>
abc
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com