python:workout
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| python:workout [2026/03/24 11:30] – [SPLAT OPERATOR] v1ctor | python:workout [2026/03/24 11:31] (current) – [GEERATORS] v1ctor | ||
|---|---|---|---|
| Line 18: | Line 18: | ||
| <code python> | <code python> | ||
| # List comprehension — builds a list | # List comprehension — builds a list | ||
| - | [pig_latin(w) for w in s.split()] | + | [some_func(w) for w in s.split()] |
| # Generator expression — produces values lazily | # Generator expression — produces values lazily | ||
| - | (pig_latin(w) for w in s.split()) | + | (some_func(w) for w in s.split()) |
| + | </ | ||
| + | |||
| + | When you pass a generator directly as the only argument to a function, you can drop the extra parentheses: | ||
| + | <code python> | ||
| + | " " | ||
| </ | </ | ||
python/workout.1774351852.txt.gz · Last modified: by v1ctor
