[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Lib calendar.py,1.17,1.18
Rob W. W. Hooft
rob@hooft.net
Mon, 16 Oct 2000 07:39:13 +0200 (CEST)
Just checking my E-mail coming back from holidays, I see:
diff -C2 -r1.17 -r1.18
*** calendar.py 2000/08/30 14:01:28 1.17
--- calendar.py 2000/10/09 12:42:04 1.18
***************
*** 55,60 ****
def leapdays(y1, y2):
"""Return number of leap years in range [y1, y2).
! Assume y1 <= y2 and no funny (non-leap century) years."""
! return (y2+3)/4 - (y1+3)/4
def weekday(year, month, day):
--- 55,62 ----
def leapdays(y1, y2):
"""Return number of leap years in range [y1, y2).
! Assume y1 <= y2."""
! y1 -= 1
! y2 -= 1
! return (y2/4 - y1/4) - (y2/100 - y1/100) + (y2/400 - y1/400)
def weekday(year, month, day):
I am worried about the use of "-=" here. The code basically says: "if the
arguments are mutable numeric types, I'd like to modify them in place". In
c.l.py it has been stressed multiple times that "-=" is not the same as
"= -". I think this is clearly a place where "= -" is preferable over
"-=". Even though you might think people will always call this with
python integers, you can never be sure enough.
Rob
--
===== rob@hooft.net http://www.hooft.net/people/rob/ =====
===== R&D, Nonius BV, Delft http://www.nonius.nl/ =====
===== PGPid 0xFA19277D ========================== Use Linux! =========