Created
March 29, 2014 05:46
-
-
Save mindcube/9849213 to your computer and use it in GitHub Desktop.
Generate a tuple of years in descending order in Python
This file contains hidden or 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 datetime import date, strftime | |
def _list_years(self): | |
x = 1 | |
years = () | |
today = date.today() | |
for x in range(15): | |
year = today - timedelta(days=365 * x) | |
years += (year.strftime('%Y'),) | |
x += 1 | |
return years |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment