/mypy-guide-generators-2.py Secret
Created
May 4, 2021 20:02
This file contains 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
from typing import Generator | |
def generator(n: int) -> Generator[str, None, int]: | |
yield 'start' | |
for i in range(n): | |
yield f'item number {i+1}' | |
yield 'end' | |
return 42 | |
for string in generator(3): | |
print(string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment