From the course: Python: Programming Efficiently

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Exploit Python collections

Exploit Python collections - Python Tutorial

From the course: Python: Programming Efficiently

Start my 1-month free trial

Exploit Python collections

- [Instructor] There's a lot that we can do with the basic Python containers, lists and dict sets. In some cases, however we need more specialized objects. The standard library module collections of several more flavors or containers which are useful in different ways. Let's look at named tuple, which describes data records, counter which counts occurrences of elements in a sequence, defaultdict to implement dictionaries with default values, and deck to manipulate double ended cues. In the first version of this course, I also presented collections or the dict, which preserves insertion order in a dictionary. But now there's no need to break it up, since beginning in Python 2.6 insertion order is preserved by the standard dict object. As usual, I start by importing old packages that I need. We continue with our Olympic theme, a loaded data set of the gold medals awarded at a Summer Games in athletics only. Let's start by…

Contents