Hacker News new | ask | show | jobs
by mlonkibjuyhv 2316 days ago
I could have sworn I have written range(1,stop) many times in Python. Did I misunderstand your argument, or has my memory gone all sideways?
2 comments

`range(stop)` and `range(1, stop)` are both supported, but without overloading, the implementation of `range` is messy as it has to work out the meaning of each argument manually.
Why is that a problem? I want the standard library to contain all messy stuff so my code doesn't have to.

From the call site there's no difference between Python's optional-first-argument range() function and a hypothetical overloaded one. Any perceived complexity in usage, therefore, can be fixed with better documentation.

`range` is an example. Lack of support for overloading makes it harder to replicate its API in our own functions.
Ah right, totally misunderstood.

Yep, true. Overloading is nice.

    range(a) means range(start=0, end=a)
    range(a, b) means range(start=a, end=b)