4 ms·
Does this mean that the mere presence of the word `yield` turns a function into a generator? Is there any way to build a yield-less generator (say, a noop gener
by wycats 13y ago
Does this mean that the mere presence of the word `yield` turns a function into a generator? Is there any way to build a yield-less generator (say, a noop generator for an API that requires a generator)?
- almost 13y agoYes it does. If you did want a generator that didn't yield anything I guess you could write: myEmptyGen = -> yield if false Which is pretty ugly, but it's not something I've needed to do often with generators (in Python at least)