fluent python 2nd edition_Fluent Python: Slice
Pyhton中序列类型支持切片功能,比如list:>>> numbers = [1, 2, 3, 4, 5]>>> numbers[1:3][2, 3]tuple也是序列类型,同样支持切片。(一)我们是否可以使自定义类型支持切片呢?在Python中创建功能完善的序列类型不需要使用继承,只要实现符合序列协议的方法就可以,Python的序列协议需要__len__, ...