What are the differences between list, sequence and slice data types in Python?

PythonServer Side ProgrammingProgramming

A list is a sequence but a sequence is not necessarily a list. A sequence is any type that supports the sequence interface ("protocol"). Sequence types describe a functional superset.

Slice objects are generally created implicitly via syntactic sugar (foo[2:5]) and provided to the container type special methods (such as __getitem__) which you can override. You will generally not have to deal with slices unless if you create your own sequences/containers.

raja
Published on 05-Jan-2018 16:52:11
Advertisements