[Python-checkins] r43590 - python/trunk/Lib/calendar.py

walter.doerwald python-checkins at python.org
Mon Apr 3 17:20:29 CEST 2006


Author: walter.doerwald
Date: Mon Apr  3 17:20:28 2006
New Revision: 43590

Modified:
   python/trunk/Lib/calendar.py
Log:
Turn firstweekday into a property.


Modified: python/trunk/Lib/calendar.py
==============================================================================
--- python/trunk/Lib/calendar.py	(original)
+++ python/trunk/Lib/calendar.py	Mon Apr  3 17:20:28 2006
@@ -130,6 +130,15 @@
     def __init__(self, firstweekday=0):
         self.firstweekday = firstweekday # 0 = Monday, 6 = Sunday
 
+    def getfirstweekday(self):
+        return self._firstweekday
+    
+    def setfirstweekday(self, firstweekday):
+        if not MONDAY <= firstweekday <= SUNDAY:
+            raise IllegalWeekdayError(firstweekday)
+        self._firstweekday = firstweekday
+    firstweekday = property(getfirstweekday, setfirstweekday)
+
     def iterweekdays(self):
         """
         Return a iterator for one week of weekday numbers starting with the
@@ -559,14 +568,8 @@
 # Support for old module level interface
 c = TextCalendar()
 
-def firstweekday():
-    return c.firstweekday
-
-def setfirstweekday(firstweekday):
-    if not MONDAY <= firstweekday <= SUNDAY:
-        raise IllegalWeekdayError(firstweekday)
-    c.firstweekday = firstweekday
-
+firstweekday = c.getfirstweekday
+setfirstweekday = c.setfirstweekday
 monthcalendar = c.monthdayscalendar
 prweek = c.prweek
 week = c.formatweek


More information about the Python-checkins mailing list