[Tutor] question about calendar module in standard libriary
Айнур Зулькарнаев
e2012 at live.ru
Mon Sep 11 06:58:51 EDT 2017
Hello all!
There is a class Calendar in calendar.py in standard libriary.
class Calendar(object):
"""
Base calendar class. This class doesn't do any formatting. It simply
provides data to subclasses.
"""
def __init__(self, firstweekday=0):
self.firstweekday = firstweekday # 0 = Monday, 6 = Sunday
def getfirstweekday(self):
return self._firstweekday % 7
def setfirstweekday(self, firstweekday):
self._firstweekday = firstweekday
firstweekday = property(getfirstweekday, setfirstweekday)
As far as I understand, even if user enters inappropriate firstweekday parameter (bigger than 6) during instansiation of the Calendar, the Calendar swallows it (and latter returns correct firstweekday value due to %7 in getfirstweekday method).
So, the question is why not explicitly raise ValueError if user enters the firstweekday parameter bigger that 6 (with accordance with the Zen). Am I missing something?
Thank you in advance
Best regards, Aynur
С уважением, А.И. Зулькарнаев
More information about the Tutor
mailing list