[Python-Dev] [Python-checkins] r43545 - in python/trunk: Doc/lib/libcalendar.tex Lib/calendar.py (original) (raw)

Walter Dörwald walter at livinglogic.de
Mon Apr 3 00:12:30 CEST 2006


Tim Peters wrote:

[Tim, gripes about ...]

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][ This is because in 2.4 there where no Calendar objects and firstweekday was only setable and getable via module level functions. I didn't realize that, of course . Skipping the rest ;-), then, it would be best to make firstweekday a property on the new base class. ... The only thing lost is the range check in the setter. Which isn't a good thing to lose. It's not good that the current Calendar constructor skips that sanity check either ("errors should never pass silently").

I've changed calendar so that firstweekday is only used modulo 7 everywhere (There was only one spot missing, all other cases used firstweekday modulo 7 anyway.

... Simple attribute access looks much more Pythonic to me than setters and gettes (especially as the attributes of subclasses are simple attributes). Or are you talking about the Calendar class itself? Yes, it would be best if Calendar had a property, so that sanity checks were performed when setting firstweekday, and also if the Calendar constructor performed that sanity check (which could happen "by magic" if firstweekday were a property).

Range checks should no longer be neccessary, as any value works now.

Bye, Walter Dörwald



More information about the Python-Dev mailing list