Created
July 12, 2011 11:01
-
-
Save RaD/1077773 to your computer and use it in GitHub Desktop.
This iterator generates the names of week day starting from `start` day.
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
def weekday_iterator(start=0): | |
""" This iterator generates the names | |
of week day starting from `start` day. """ | |
names = ('mo', 'tu', 'we', 'th', 'fr', 'sa', 'su',) | |
maximum = len(names) | |
i = 0 | |
while i < maximum: | |
index = (start + i) % maximum | |
value = names[index] | |
i += 1 | |
yield (index, value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: