Stats

3770 Contributors: 55 Monday, July 10, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Generators

Introduction

Generators are lazy iterators created by generator functions (using yield) or generator expressions (using (an_expression for x in an_iterator)).

Syntax

  • yield <expr>
  • yield from <expr>
  • <var> = yield <expr>
  • next(<iter>)

Related Examples