In python, how do I check if an object is a generator object?
Trying this -
>>> type(myobject, generator)
gives the error -
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'generator' is not defined
(I know I can check if the object has a next
method for it to be a generator, but I want some way using which I can determine the type of any object, not just generators.)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…