Python in Plain English

New Python content every day. Follow to join our 3.5M+ monthly readers.

Follow publication

Member-only story

Python Iterators, Generators And Decorators Made Easy

Naina Chaturvedi
Python in Plain English
11 min readSep 16, 2020

--

Pic from Unsplash.com

Recently I received an email from one of my readers asking me to write about Python’s complex topics such as Iterators, Generators, and Decorators. In this post, I’m going to cover the basics, implementation, and how to use them in your code.

Projects Videos —

All the projects, data structures, SQL, algorithms, system design, Data Science and ML , Data Analytics, Data Engineering, , Implemented Data Science and ML projects, Implemented Data Engineering Projects, Implemented Deep Learning Projects, Implemented Machine Learning Ops Projects, Implemented Time Series Analysis and Forecasting Projects, Implemented Applied Machine Learning Projects, Implemented Tensorflow and Keras Projects, Implemented PyTorch Projects, Implemented Scikit Learn Projects, Implemented Big Data Projects, Implemented Cloud Machine Learning Projects, Implemented Neural Networks Projects, Implemented OpenCV Projects,Complete ML Research Papers Summarized, Implemented Data Analytics projects, Implemented Data Visualization Projects, Implemented Data Mining Projects, Implemented Natural Leaning Processing Projects, MLOps and Deep Learning, Applied Machine Learning with Projects Series, PyTorch with Projects Series, Tensorflow and Keras with Projects Series, Scikit Learn Series with Projects, Time Series Analysis and Forecasting with Projects Series, ML System Design Case Studies Series videos will be published on our youtube channel ( just launched).

Subscribe today!

Let’s dive in!

  1. Iterators: In Python, an iterator is an object that implements the __iter__ method and the __next__ method, allowing it to be used in a for loop or with the next function. The __iter__ method returns the iterator object itself, and the __next__ method returns the next value in the iteration. When there are no more values to return, the __next__ method raises a StopIteration exception.
  2. Generators: A generator is a special type

--

--

Published in Python in Plain English

New Python content every day. Follow to join our 3.5M+ monthly readers.

Written by Naina Chaturvedi

🇺🇸,World Traveler, Sr. SDE, Researcher Cornell Uni, Women in Tech, Coursera Instructor ML & GCP, Trekker, IITB,Reader,I write for fun@AI & Python publications