We’ll take a deep dive into the itertools module and look at all the functions available there and how useful (but overlooked!) they can be. File size: 18.99 GB
Python 3: Deep Dive (Part 2 – Iteration, Generators)
What you’ll learn
You’ll be able to leverage the concepts in this course to take your Python programming skills to the next level.
Sequence Types and the sequence protocol
Iterables and the iterable protocol
Iterators and the iterator protocol
List comprehensions and their relation to closures
Generator functions
Generator expressions
Context managers
Creating context managers using generator functions
Using Generators as Coroutines
Get immediately download Python 3: Deep Dive (Part 2 – Iteration, Generators)
Course content
Expand all 137 lectures34:40:22
–Introduction
15:37
Course Overview
Preview
06:30
Pre-Requisites
Preview
06:04
Python Tools Needed
Preview
03:03
–Sequence Types
07:55:14
Introduction
Preview
01:23
Sequence Types – Lecture
Preview
17:10
Sequence Types – Coding
Preview
27:23
Mutable Sequence Types – Lecture
07:18
Mutable Sequence Types – Coding
18:06
Lists vs Tuples
21:50
Index Base and Slice Bounds – Rationale
15:14
Copying Sequences – Lecture
29:25
Copying Sequences – Coding
23:28
Slicing – Lecture
32:08
Slicing – Coding
14:42
Custom Sequences – Part 1 – Lecture
10:40
Custom Sequences – Part 1 – Coding
34:00
In-Place Concatenation and Repetition – Lecture
05:34
In-Place Concatenation and Repetition – Coding
07:27
Assignments in Mutable Sequences – Lecture
07:03
Assignments in Mutable Sequences – Coding
10:19
Custom Sequences – Part 2 – Lecture
09:17
Custom Sequences – Part 2A – Coding
17:54
Custom Sequences – Part 2B – Coding
34:49
Custom Sequences – Part 2C – Coding
21:10
Sorting Sequences – Lecture
17:52
Sorting Sequences – Coding
25:52
List Comprehensions – Lecture
17:54
List Comprehensions – Coding
47:16
–Project 1
01:00:16
Project Description
Preview
07:32
Project Solution: Goal 1
40:31
Project Solution: Goal 2
12:13
–Iterables and Iterators
04:51:39
Introduction
Preview
02:53
Iterating Collections – Lecture
11:19
Iterating Collections – Coding
20:18
Iterators – Lecture
06:21
Iterators – Coding
11:44
Iterators and Iterables – Lecture
11:22
Iterators and Iterables – Coding
28:03
Example 1 – Consuming Iterators Manually
26:31
Example 2 – Cyclic Iterators
31:33
Lazy Iterables – Lecture
03:44
Lazy Iterables – Coding
14:59
Python’s Built-In Iterables and Iterators – Lecture
02:24
Python’s Built-In Iterables and Iterators – Coding
14:21
Sorting Iterables
08:51
The iter() Function – Lecture
06:26
The iter() Function – Coding
13:59
Iterating Callables – Lecture
04:42
Iterating Callables – Coding
15:53
Example 3 – Delegating Iterators
07:41
Reversed Iteration – Lecture
09:49
Reversed Iteration – Coding
20:00
Caveat: Using Iterators as Function Arguments
18:46
–Project 2
17:01
Project Description
Preview
03:29
Project Solution: Goal 1
05:50
Project Solution: Goal 2
07:42
–Generators
02:11:27
Introduction
Preview
01:21
Yielding and Generator Functions – Lecture
17:38
Yielding and Generator Functions – Coding
17:33
Example – Fibonacci Sequence
15:31
Making an Iterable from a Generator – Lecture
06:59
Making an Iterable from a Generator – Coding
06:40
Example – Card Deck
11:04
Generator Expressions and Performance – Lecture
09:17
Generator Expressions and Performance – Coding
30:19
Yield From – Lecture
02:36
Yield From – Coding
12:29
–Project 3
01:01:58
Project Description
Preview
04:15
Project Solution: Goal 1
41:46
Project Solution: Goal 2
15:57
–Iteration Tools
04:25:49
Introduction
Preview
04:22
Aggregators – Lecture
10:05
Aggregators – Coding
26:28
Slicing – Lecture
03:18
Slicing – Coding
11:33
Selecting and Filtering – Lecture
10:02
Selecting and Filtering – Coding
15:07
Infinite Iterators – Lecture
05:29
Infinite Iterators – Coding
18:49
Chaining and Teeing – Lecture
08:40
Chaining and Teeing – Coding
18:51
Mapping and Reducing – Lecture
15:54
Mapping and Reducing – Coding
18:16
Zipping – Lecture
03:15
Zipping – Coding
06:54
Grouping – Lecture
10:00
Grouping – Coding
27:01
Combinatorics – Lecture
09:30
Combinatorics – Coding (Product)
21:26
Combinatorics – Coding (Permutation, Combination)
20:49
–Project 4
02:32:14
Project – Description
Preview
11:49
Project Solution: Goal 1
43:50
Project Solution: Goal 2
38:41
Project Solution: Goal 3
07:17
Project Solution: Goal 4
50:37
–Context Managers
03:34:00
Introduction
Preview
08:02
Context Managers – Lecture
22:46
Context Managers – Coding
37:10
Caveat when used with Lazy Iterators
03:49
Not just a Context Manager
07:33
Additional Uses – Lecture
06:04
Additional Uses – Coding
36:03
Generators and Context Managers – Lecture
10:46
Generators and Context Managers – Coding
13:12
The contextmanager Decorator – Lecture
09:41
The contextmanager Decorator – Coding
24:26
Nested Context Managers
34:28
3 more sections
Requirements
This is a relatively advanced course, so you should already be familiar with basic Python concepts, as well as some in-depth knowledge as described in the prerequisites in the course description. Please be sure you check those and make sure!
You will need Python 3.6 or above, and a development environment of your choice (command line, PyCharm, Jupyter, etc.)
Get immediately download Python 3: Deep Dive (Part 2 – Iteration, Generators)
Description
Part 2 of this Python 3: Deep Dive series is an in-depth look at:
sequences
iterables
iterators
generators
comprehensions
context managers
generator based coroutines
I will show you exactly how iteration works in Python – from the sequence protocol, to the iterable and iterator protocols, and how we can write our own sequence and iterable data types.
We’ll go into some detail to explain sequence slicing and how slicing relates to ranges.
We look at comprehensions in detail as well and I will show you how list comprehensions are actually closures and have their own scope, and the reason why subtle bugs sometimes creep in to list comprehensions that we might not expect.
We’ll take a deep dive into the itertools module and look at all the functions available there and how useful (but overlooked!) they can be.
We also look at generator functions, their relation to iterators, and their comprehension counterparts (generator expressions).
Context managers, an often overlooked construct in Python, is covered in detail too. There we will learn how to create and leverage our own context managers and understand the relationship between context managers and generator functions.
Finally, we’ll look at how we can use generators to create coroutines.
Each section is followed by a project designed to put into practice what you learn throughout the course.
This course series is focused on the Python language and the standard library. There is an enormous amount of functionality and things to understand in just the standard CPython distribution, so I do not cover 3rd party libraries – this is a Python deep dive, not an exploration of the many highly useful 3rd party libraries that have grown around Python – those are often sufficiently large to warrant an entire course unto themselves! Indeed, many of them already do!
***** Prerequisites *****
Please note that this is a relatively advanced Python course, and a strong knowledge of some topics in Python is required.
In particular you should already have an in-depth understanding of the following topics:
functions and function arguments
packing and unpacking iterables and how that is used with function arguments (i.e. using *)
closures
decorators
Boolean truth values and how any object has an associated truth value
named tuples
the zip, map, filter, sorted, reduce functions
lambdas
importing modules and packages
You should also have a basic knowledge of the following topics:
various data types (numeric, string, lists, tuples, dictionaries, sets, etc)
for loops, while loops, break, continue, the else clause
if statements
try…except…else…finally…
basic knowledge of how to create and use classes (methods, properties) – no need for advanced topics such as inheritance or meta classes
understand how certain special methods are used in classes (such as __init__, __eq__, __lt__, etc)
Who this course is for:
Python developers who want a deeper understanding of sequences, iterables, iterators, generators and context managers.