Created
November 14, 2017 16:42
-
-
Save vodik/6533a34696e8b9884e8769002a6087f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def wrapper(iterable): | |
print("start") | |
results = yield from iterable | |
print("stop") | |
results[:] = [1, 1, 1] | |
return results | |
def multicall(*callables): | |
all_results = [] | |
for c in callables: | |
result = c() | |
all_results.append(result) | |
yield result | |
return all_results | |
results = wrapper(multicall(lambda: 1, lambda: 2, lambda: 3)) | |
try: | |
print(next(results)) | |
print(next(results)) | |
print(next(results)) | |
print(next(results)) | |
except StopIteration as e: | |
assert e.value == [1, 1, 1] | |
print(e.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment