3 Using built-in data containers

This chapter covers

  • Choosing lists over tuples and vice versa
  • Sorting lists that consist of complex data types
  • Using named tuples as a data container model
  • Accessing a dictionary’s data
  • Understanding hashability and its implications for dictionaries and sets
  • Applying set operations to manipulate nonset data

As a general-purpose programming language, Python provides a range of built-in data types for different purposes, including collection types. These collection types of data serve as containers to hold integers, strings, instances of custom classes, and all other kinds of objects. In every project, we deal with multiple objects at the same time, and these scenarios often require data containers to handle these ...

Get Python How-To now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.