Using List Comprehensions Effectively
Dan Bader
13:45
Description
This short course breaks down Python list comprehensions for you step by step. See how Python’s comprehensions can be transformed from and to equivalent “for”-loops so you’ll know exactly what’s going on behind the scenes.
One of my favorite features in Python are list comprehensions. They can seem a bit arcane at first but when you break them down they are actually a very simple construct.
The key to understanding Python’s list comprehensions is that they’re just for-loops over a collection expressed in a more terse and compact syntax.
In the course you’ll also learn when to use list comprehensions in your own Python programs and when not to. Basically, the caveat to Python’s comprehensions is this—as you get more proficient at using them it becomes easier and easier to write code that’s difficult to read.
If you’re not careful you might have to deal with monstrous list, set, dict comprehensions soon. Too much of a good thing is usually a bad thing.
What You'll Learn?
- Comprehending Python’s Comprehensions
More details
User Reviews
Rating
Dan Bader
Instructor's CoursesDan Bader is the owner and editor in chief of Real Python and the main developer of the realpython.com learning platform. Dan has been writing code for more than 20 years and holds a master’s degree in computer science. He’s the author of Python Tricks, a best selling programming book for intermediate Python developers.
Hey, I’m Dan Bader and I help Python developers take their coding skills and productivity to the next level. I’m an independent software engineer, author, and speaker. I’ve been writing code for more than two decades—and I’d love to help you become a more proficient Python coder.
Here’s where you can find me elsewhere on the web:
I’ve also done some podcast interviews and other media appearances you can check out:

Real Python
View courses Real Python- language english
- Training sessions 8
- duration 13:45
- Release Date 2023/01/05