[Python-checkins] r55394 - python/trunk/Lib/calendar.py
raymond.hettinger
python-checkins at python.org
Thu May 17 03:08:09 CEST 2007
Author: raymond.hettinger
Date: Thu May 17 03:08:04 2007
New Revision: 55394
Modified:
python/trunk/Lib/calendar.py
Log:
calendar.py gets no benefit from xrange() instead of range()
Modified: python/trunk/Lib/calendar.py
==============================================================================
--- python/trunk/Lib/calendar.py (original)
+++ python/trunk/Lib/calendar.py Thu May 17 03:08:04 2007
@@ -45,7 +45,7 @@
class _localized_month:
- _months = [datetime.date(2001, i+1, 1).strftime for i in xrange(12)]
+ _months = [datetime.date(2001, i+1, 1).strftime for i in range(12)]
_months.insert(0, lambda x: "")
def __init__(self, format):
@@ -65,7 +65,7 @@
class _localized_day:
# January 1, 2001, was a Monday.
- _days = [datetime.date(2001, 1, i+1).strftime for i in xrange(7)]
+ _days = [datetime.date(2001, 1, i+1).strftime for i in range(7)]
def __init__(self, format):
self.format = format
@@ -144,7 +144,7 @@
Return a iterator for one week of weekday numbers starting with the
configured first one.
"""
- for i in xrange(self.firstweekday, self.firstweekday + 7):
+ for i in range(self.firstweekday, self.firstweekday + 7):
yield i%7
def itermonthdates(self, year, month):
@@ -192,7 +192,7 @@
Each row represents a week; week entries are datetime.date values.
"""
dates = list(self.itermonthdates(year, month))
- return [ dates[i:i+7] for i in xrange(0, len(dates), 7) ]
+ return [ dates[i:i+7] for i in range(0, len(dates), 7) ]
def monthdays2calendar(self, year, month):
"""
@@ -202,7 +202,7 @@
are zero.
"""
days = list(self.itermonthdays2(year, month))
- return [ days[i:i+7] for i in xrange(0, len(days), 7) ]
+ return [ days[i:i+7] for i in range(0, len(days), 7) ]
def monthdayscalendar(self, year, month):
"""
@@ -210,7 +210,7 @@
Each row represents a week; days outside this month are zero.
"""
days = list(self.itermonthdays(year, month))
- return [ days[i:i+7] for i in xrange(0, len(days), 7) ]
+ return [ days[i:i+7] for i in range(0, len(days), 7) ]
def yeardatescalendar(self, year, width=3):
"""
@@ -221,9 +221,9 @@
"""
months = [
self.monthdatescalendar(year, i)
- for i in xrange(January, January+12)
+ for i in range(January, January+12)
]
- return [months[i:i+width] for i in xrange(0, len(months), width) ]
+ return [months[i:i+width] for i in range(0, len(months), width) ]
def yeardays2calendar(self, year, width=3):
"""
@@ -234,9 +234,9 @@
"""
months = [
self.monthdays2calendar(year, i)
- for i in xrange(January, January+12)
+ for i in range(January, January+12)
]
- return [months[i:i+width] for i in xrange(0, len(months), width) ]
+ return [months[i:i+width] for i in range(0, len(months), width) ]
def yeardayscalendar(self, year, width=3):
"""
@@ -246,9 +246,9 @@
"""
months = [
self.monthdayscalendar(year, i)
- for i in xrange(January, January+12)
+ for i in range(January, January+12)
]
- return [months[i:i+width] for i in xrange(0, len(months), width) ]
+ return [months[i:i+width] for i in range(0, len(months), width) ]
class TextCalendar(Calendar):
@@ -341,7 +341,7 @@
header = self.formatweekheader(w)
for (i, row) in enumerate(self.yeardays2calendar(theyear, m)):
# months in this row
- months = xrange(m*i+1, min(m*(i+1)+1, 13))
+ months = range(m*i+1, min(m*(i+1)+1, 13))
a('\n'*l)
names = (self.formatmonthname(theyear, k, colwidth, False)
for k in months)
@@ -352,7 +352,7 @@
a('\n'*l)
# max number of weeks for this row
height = max(len(cal) for cal in row)
- for j in xrange(height):
+ for j in range(height):
weeks = []
for cal in row:
if j >= len(cal):
@@ -444,9 +444,9 @@
a('<table border="0" cellpadding="0" cellspacing="0" class="year">')
a('\n')
a('<tr><th colspan="%d" class="year">%s</th></tr>' % (width, theyear))
- for i in xrange(January, January+12, width):
+ for i in range(January, January+12, width):
# months in this row
- months = xrange(i, min(i+width, 13))
+ months = range(i, min(i+width, 13))
a('<tr>')
for m in months:
a('<td>')
More information about the Python-checkins
mailing list