How to check if an object is a generator object in python?
You can use GeneratorType from types:
>>> import types
>>> types.GeneratorType
<class 'generator'>
>>> gen = (i for i in range(10))
>>> isinstance(gen, types.GeneratorType)
True
You mean generator functions ? use inspect.isgeneratorfunction
.
EDIT :
if you want a generator object you can use inspect.isgenerator as pointed out by JAB in his comment.