Udemy
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Development
Web Development Data Science Mobile Development Programming Languages Game Development Database Design & Development Software Testing Software Engineering Development Tools No-Code Development
Business
Entrepreneurship Communications Management Sales Business Strategy Operations Project Management Business Law Business Analytics & Intelligence Human Resources Industry E-Commerce Media Real Estate Other Business
Finance & Accounting
Accounting & Bookkeeping Compliance Cryptocurrency & Blockchain Economics Finance Finance Cert & Exam Prep Financial Modeling & Analysis Investing & Trading Money Management Tools Taxes Other Finance & Accounting
IT & Software
IT Certification Network & Security Hardware Operating Systems Other IT & Software
Office Productivity
Microsoft Apple Google SAP Oracle Other Office Productivity
Personal Development
Personal Transformation Personal Productivity Leadership Career Development Parenting & Relationships Happiness Esoteric Practices Religion & Spirituality Personal Brand Building Creativity Influence Self Esteem & Confidence Stress Management Memory & Study Skills Motivation Other Personal Development
Design
Web Design Graphic Design & Illustration Design Tools User Experience Design Game Design Design Thinking 3D & Animation Fashion Design Architectural Design Interior Design Other Design
Marketing
Digital Marketing Search Engine Optimization Social Media Marketing Branding Marketing Fundamentals Marketing Analytics & Automation Public Relations Advertising Video & Mobile Marketing Content Marketing Growth Hacking Affiliate Marketing Product Marketing Other Marketing
Lifestyle
Arts & Crafts Beauty & Makeup Esoteric Practices Food & Beverage Gaming Home Improvement Pet Care & Training Travel Other Lifestyle
Photography & Video
Digital Photography Photography Portrait Photography Photography Tools Commercial Photography Video Design Other Photography & Video
Health & Fitness
Fitness General Health Sports Nutrition Yoga Mental Health Dieting Self Defense Safety & First Aid Dance Meditation Other Health & Fitness
Music
Instruments Music Production Music Fundamentals Vocal Music Techniques Music Software Other Music
Teaching & Academics
Engineering Humanities Math Science Online Education Social Science Language Teacher Training Test Prep Other Teaching & Academics
AWS Certification Microsoft Certification AWS Certified Solutions Architect - Associate AWS Certified Cloud Practitioner CompTIA A+ Cisco CCNA Amazon AWS CompTIA Security+ AWS Certified Developer - Associate
Graphic Design Photoshop Adobe Illustrator Drawing Digital Painting InDesign Character Design Canva Figure Drawing
Life Coach Training Neuro-Linguistic Programming Personal Development Mindfulness Meditation Personal Transformation Life Purpose Emotional Intelligence Neuroscience
Web Development JavaScript React CSS Angular PHP WordPress Node.Js Python
Google Flutter Android Development iOS Development Swift React Native Dart Programming Language Mobile Development Kotlin SwiftUI
Digital Marketing Google Ads (Adwords) Social Media Marketing Google Ads (AdWords) Certification Marketing Strategy Internet Marketing YouTube Marketing Email Marketing Google Analytics
SQL Microsoft Power BI Tableau Business Analysis Business Intelligence MySQL Data Modeling Data Analysis Big Data
Business Fundamentals Entrepreneurship Fundamentals Business Strategy Online Business Business Plan Startup Blogging Freelancing Home Business
Unity Game Development Fundamentals Unreal Engine C# 3D Game Development C++ 2D Game Development Unreal Engine Blueprints Blender
30-Day Money-Back Guarantee
Development Programming Languages Python

Python 3: Deep Dive (Part 2 - Iteration, Generators)

Sequences, Iterables, Iterators, Generators, Context Managers and Generator-based Coroutines
Rating: 4.8 out of 54.8 (1,189 ratings)
18,105 students
Created by Fred Baptiste
Last updated 8/2020
English
30-Day Money-Back Guarantee

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
Curated for the Udemy for Business collection

Course content

13 sections • 138 lectures • 34h 40m total length

  • Preview06:30
  • Preview06:04
  • Preview03:03

  • Preview01:23
  • Preview17:10
  • Preview27: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

  • Preview07:32
  • Project Solution: Goal 1
    40:31
  • Project Solution: Goal 2
    12:13

  • Preview02: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

  • Preview03:29
  • Project Solution: Goal 1
    05:50
  • Project Solution: Goal 2
    07:42

  • Preview01: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

  • Preview04:15
  • Project Solution: Goal 1
    41:46
  • Project Solution: Goal 2
    15:57

  • Preview04: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

  • Preview11: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

  • Preview08: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

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.)

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.

Featured review

Malvina Pushkova
Malvina Pushkova
130 courses
11 reviews
Rating: 5.0 out of 510 months ago
This is a continuation of part 1. Though the content became even more complicated. If you are not a professional programmer than it can be a good idea to take the first 4 sections of the course and skip the last 2 sections until you gain sufficient experience.

Instructor

Fred Baptiste
Professional Developer and Mathematician
Fred Baptiste
  • 4.8 Instructor Rating
  • 8,468 Reviews
  • 30,734 Students
  • 4 Courses

Hi,

My name is Fred Baptiste.

I started my career with a PhD in mathematics and have been programming professionally for over 25 years in a variety of technologies and languages, including Python, .Net (C# and VB), Java, C++, and JavaScript to name a few, and databases including relational SQL databases such as MS SQL Server and Postgres as well as No-SQL databases such as MongoDB, Couchbase and Neo4j.

Since 2011 I have been focused on Python almost exclusively, mainly in REST API development and data management and analysis.

I have spent a lot of time and effort learning and gaining an in-depth understanding of Python and writing idiomatic Python, and I'd like to share that with you.

I'm definitely a Python enthusiast for many reasons, and I'd like to share that passion with you too!

  • Udemy for Business
  • Teach on Udemy
  • Get the app
  • About us
  • Contact us
  • Careers
  • Blog
  • Help and Support
  • Affiliate
  • Impressum Kontakt
  • Terms
  • Privacy policy
  • Cookie settings
  • Sitemap
  • Featured courses
Udemy
© 2021 Udemy, Inc.