Event Timeline
Comment Actions
why not something like:
if res is None: return None else: yield res yield from stream_results(f, page_token = res.page_token, **kwargs)
(not sure about the page_token API here)
Comment Actions
Because, if there is a single yield expression in the function's AST, Python parses the function as a generator, so it can only return generator objects None.
>>> def f(): ... if True: ... return None ... else: ... yield 42 ... >>> f() <generator object f at 0x7fc494dbc7c8> >>> list(f()) []
Comment Actions
ok then
return itertools.chain([res], stream_results(f, page_token = res.page_token, **kwargs))
(note sure it's really better, but...)