What's the difference between a reversed tuple and a reversed list?
问题 Reversing a tuple and reversing a list returns objects of different type: >>> reversed((1,2)) <reversed at 0x7fffe802f748> >>> reversed([1,2]) <list_reverseiterator at 0x7fffebdd4400> They have the same dir . Neither type is a subclass of the other. Why is that? What can one do that the other can't? 回答1: Basically, a list implements the __reversed__ method and returns an specialized object, while tuple falls back to the default implementation of reversed for any sequence: >>> list.__reversed_