Rob W. W. Hooft: > Just checking my E-mail coming back from holidays, I see: [...] > 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) > > 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. Hmm... Your fear sounds a little paranoid for this particular case, but I can't say that I totally disagree in general. This is definitely something to keep in mind when writing polymorphic functions for which a NumPy array might be an acceptable input argument. I don't think it's worth checking in a patch in this case. --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4