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

Walter Dörwald walter at livinglogic.de
Sun Apr 2 10:24:04 CEST 2006


Tim Peters wrote:

>> 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.

This is because in 2.4 there where no Calendar objects and firstweekday was only setable and getable via module level functions.

> If so, then (a) the functionality of the Calendar class is weaker now,

No really. firstweekday is changeable simply by assigning to the attribute:

import calendar
cal = calendar.Calendar()
cal.firstweekday = 6

The only thing lost is the range check in the setter.

> and in a
> backward-incompatible way;

Yes, this change is backwards-incompatible, but imcompatible to code that has been in the repository since Friday, so this
shouldn't be a problem! ;)
> 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.

That's because in 2.4 the module level interface was all there was.

> I don't see the attraction to any part of this.

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?

> [...]

Bye,
   Walter Dörwald





More information about the Python-Dev mailing list