def newg(*args, **kwargs): assert not isgeneratorfunction(g), 'Only use for non-generators.' raise StopIteration(g(*args, **kwargs)) yield