From the course: Advanced Python (2018)
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
Itertools - Python Tutorial
From the course: Advanced Python (2018)
Itertools
- [Narrator] Since iterating over data is such an important part of Python, I'm going to include a discussion of an important module here which is called Itertools. Now this is not technically a set of built in language functions, but they are part of the standard library that comes with Python, and they are incredibly useful for creating iterators to handle a variety of common scenarios. And to use them, you just need to import the Itertools module. So over in the code, I've got my Itertools underscore start file open. At the top, I'll import Itertools, all right. So let's take a loot at some of the more useful tools in this module, and I'll start by demonstrating a couple of infinite iterators, and these are iterators that will generate values for as long as you need them and they just never end. So the first is called cycle, and it does what its name implies, it cycles over a set of values. So I have a sequence of names here, and I'm going to create a cycle iterator by calling…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.