I need to check if a certain variable is a generator object.
How would I specify the literal generator type in place of the ??? below?
def go():
for i in range(999):
yield i
la = go()
print repr(type(la))
<type 'generator'>
assert type(la) == ???
In general you wouldn’t. You’d look for attributes with the names of
__iter__andnext, both functions.