[Python-Dev] [Python-checkins] r43545 - in python/trunk: Doc/lib/libcalendar.tex Lib/calendar.py
Tim Peters
tim.peters at gmail.com
Sun Apr 2 00:43:41 CEST 2006
> Author: walter.doerwald
> Date: Sat Apr 1 22:40:23 2006
> New Revision: 43545
>
> Modified:
> python/trunk/Doc/lib/libcalendar.tex
> python/trunk/Lib/calendar.py
> Log:
> Make firstweekday a simple attribute instead
> of hiding it behind a setter and a getter.
Walter, what's the purpose of this patch? The first weekday is still
an attribute, but instead of being settable and gettable via methods,
looks like it's now settable and gettable via module-global functions,
and only for the single default instance of Calendar created by the
module. If so, then (a) the functionality of the Calendar class is
weaker now, and in a backward-incompatible way; and, (b) the new
module-global firstweekday() and setfirstweekday() functions are a
more obscure way to restore the lost functionality for just one
specific instance of a Calendar subclass.
I don't see the attraction to any part of this.
> --- python/trunk/Lib/calendar.py (original)
> +++ python/trunk/Lib/calendar.py Sat Apr 1 22:40:23 2006
> @@ -128,25 +128,14 @@
> """
>
> def __init__(self, firstweekday=0):
> - self._firstweekday = firstweekday # 0 = Monday, 6 = Sunday
> -
> - def firstweekday(self):
> - return self._firstweekday
> -
> - def setfirstweekday(self, weekday):
> - """
> - Set weekday (Monday=0, Sunday=6) to start each week.
> - """
> - if not MONDAY <= weekday <= SUNDAY:
> - raise IllegalWeekdayError(weekday)
> - self._firstweekday = weekday
> + self.firstweekday = firstweekday # 0 = Monday, 6 = Sunday
Removing those Calendar methods is backward-incompatible,
...
> -firstweekday = c.firstweekday
> -setfirstweekday = c.setfirstweekday
> +def firstweekday():
> + return c.firstweekday
> +
> +def setfirstweekday(firstweekday):
> + if not MONDAY <= firstweekday <= SUNDAY:
> + raise IllegalWeekdayError(firstweekday)
> + c.firstweekday = firstweekday
> +
> monthcalendar = c.monthdayscalendar
> prweek = c.prweek
And here they're obscurely added back again, but work only for the
module-global default instance `c` of the TextCalendar subclass.
More information about the Python-Dev
mailing list