Skip to content

Instantly share code, notes, and snippets.

@moreati
Created May 26, 2025 09:26
Show Gist options
  • Save moreati/c255aceee080c2f504efa979c2a6459d to your computer and use it in GitHub Desktop.
Save moreati/c255aceee080c2f504efa979c2a6459d to your computer and use it in GitHub Desktop.
Python's "yield from" cna be used with a sequence
TODAY = [
'Haircut',
'Buy milk',
]
TONIGHT = [
'Try to take over the world!',
]
def todo_items():
yield from TODAY
yield from TONIGHT
if __name__ == '__main__':
for item in todo_items():
print(f'- [] {item}')
@moreati
Copy link
Author

moreati commented May 26, 2025

$ python yield_from_seq.py
- [] Haircut
- [] Buy milk
- [] Try to take over the world!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment