Lesson 2 - Iterators, Generators and Some Functions in Python New
In the last lesson, Python Collections - Tuples and Lists, we learned in depth about working with tuples and lists.
In this lesson, we'll introduce some of the more advanced techniques of functional programming in Python. Let's look at lambda functions, iterators and generators, and a few built-in functions.
Iterators and Generators
Iterators are objects that have the special
method and return a single value each time. Iterators are a subset of
iterable objects that have the special
__iter__ method. We used
iterable objects, for example, in the
for loop. But let's go back
to the iterators. We create an iterator using the
from an iterable object, such as a list.
...End of the preview...
You've come here and that's great! We believe that the first lessons showed you something new and useful
Do you want to continue the course? Go to the premium section.
- Unlimited and permanent access to individual lessons.
- High quality IT knowledge.
- Skills to help you get your dream and well-paid job.
Requested article covers this content:
In this tutorial we'll take a look at iterators and generators. We'll also deepen our knowledge of comprehensions and learn a few built-in functions.
You gain points by supporting our network. This is done by sending a helpful amount of money to support the site, or by creating content for the network.