forked from fsr/python-lessons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This addresses issue fsr#18 and adds correct syntax.
- Loading branch information
Showing
3 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# liefert gerade Zahlen von 0 bis 10 (10 nicht enthalten) | ||
generator = (i for i in range(10) if i % 2 == 0) | ||
|
||
# gibt 0, 2, 4, 6 und 8 aus | ||
for number in generator: | ||
print(number) | ||
|
||
# gibt nichts aus, generator ist erschöpft | ||
for number in generator: | ||
print(number) | ||
|
||
# wenn alle Elemente sofort erzeugt werden würde mindestens 4GB Speicher benötigt | ||
for number in (i for i in range(2**32)): | ||
print(number) |
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