Python Lists: Ordering, Mutability, Indexing, and Slicing
Summary
This introductory article explains Python’s built-in data types, distinguishing ordered sequences such as lists, tuples, and strings from sets and dictionaries. Its main focus is the list: an ordered, resizable collection that can contain objects of different types. It explains that list positions begin at zero and introduces indexing and slicing, including the use of negative indices and omitted slice bounds to select items from the beginning or end.
The material is conceptual rather than trading-specific, but these operations are foundational when working with market data, indicators, and strategy inputs in Python. The article gives simple examples of collection forms but, in the provided text, does not show further worked list operations or discuss performance considerations. Its brief descriptions of other types provide context; the practical instruction centers on list structure and access.
Key ideas
- Python lists are ordered collections that can change size.
- List indexing starts at zero, while negative indices count from the end.
- Slicing selects a range of elements, and omitted bounds can include an endpoint of the list.
- Tuples, strings, sets, and dictionaries have different ordering and mutability properties.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.