Python Generator | Yield Statement
Have you ever had to work with a dataset so large that it overwhelmed your machine’s memory? Or maybe you have a complex function that needs to maintain an internal state every time it’s called, but the function is too small to justify creating its own class. In these cases and more, generators and the Python yield statement are here to help.
Generator functions are a special kind of function that returns a lazy iterator. These are objects that you can loop over like a list. However, unlike lists, lazy iterators do not store their contents in memory.
Now that you have a rough idea of what a generator does, you might wonder what they look like in action.
Python generators are a simple way of creating iterators. All the work we mentioned above is automatically handled by generators in Python.
Simply speaking, a generator is a function that returns an object (iterator) which we can iterate over (one value at a time).
In this course, you will get an understanding of Generator in Python including definition, examples, illustrations, use cases and exercise with solutions.
The solution is created with discussion to enhance concept building.
By the end of this course, you will get a clear understanding of;
-Generator
-Yield Statement
-Syntax
-Use cases
-Simple to complex examples.
-Exercise with solution
At the end of the course, you can access jupyter notebook code file.
Lets, Begin to dive into the deep interesting knowledge.
Stay Tuned!!