Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



and 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)`


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




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: