|
|
|
|
|
by quietbritishjim
1639 days ago
|
|
They didn't say they hadn't used generators at all. They said they hadn't made use of "returning a value from a generator" which is different from the usual method of yielding from them. def my_generator():
yield 1
yield 2
return 3
If you use that generator in a for loop then it will only put 1 and 2 into the iterator variable. You have to use the generator in a more direct way to get access to the 3.I haven't made use of return values from generators in my code either, but I believe they're used under the hood in coroutines in async code. |
|