Filtering List Comprehensions
In this lesson, you’ll see that list comprehensions are often recommended by Python core developers as a more Pythonic solution than the
filter() function you used in the previous lesson.
You can also skip the middle man and use a generator expression to get the same result but not create a list in the process. A generator expressions defines an ad hoc iterator that then produces values for you without first creating a list, and then creating a tuple from that list, and then destroying the list again, so it’s more memory efficient.
Comments & Discussion
Become a Member to join the conversation.