Runtime Types
types.GeneratorType — runtime type
Identifies generator iterators returned by functions containing yield or generator expressions. Execution resumes at each next or send operation and can be suspended; an exhausted generator raises StopIteration. Use close() when abandoning generators that own resources. It is not a general iterable check.
Formal Syntax & Structure
python syntaxpython
types.GeneratorTypeReturn Value
type
The class object types.GeneratorType; this reference documents the class identity, not a universal constructor signature.
Working Example
Example Snippetpython
import typesvalue = (n for n in range(2))print(isinstance(value, types.GeneratorType))