4 ms·
but sum and range are able to be tested in isolation and will be reused across the application, making a bug in them more visible - rather than repeating the lo
by netcraft 12y ago
but sum and range are able to be tested in isolation and will be reused across the application, making a bug in them more visible - rather than repeating the logic of the loop in every instance where you need a loop. Also, when maintaining the code later, the signal to noise ratio is much higher, you can see exactly what is being attempted, not the implementation details of it.
There are certainly times when you need to see the implementation details or that your needs don't fit the prescribed and available functions (eg, range being exclusive vs inclusive), but then if that is the exception rather than the rule, it will serve as another indicator when you come across that code that `this is doing something different than usual`, so pay attention to the details.
- deleted 12y ago[deleted]
- iopq 12y agoand then you forget range(1, 10) is a half-open interval because it's meant to be used with `length` as in `range(0, foo.length)`
- serrimo 12y agoThat part has always annoyed me. But then Python beat me into submission with its seductive collection comprehension... Now I see it as a standard convention, like indexing should start with 0.