On Dec 4, 2019, at 06:57, Marein <python-ideas@marein.net> wrote:
I was using it like this: range(start, end, sign(end-start)), to automatically have a range going up or down. But that's really the only concrete case I know.
If your only use for non-float-specific copysign would be implementing sign, why not ask for sign instead? It seems much more directly useful here, and potentially more widely useful as well. But I don’t think that’s needed either. It still doesn’t come up that often, and when it does, anyone can implement it trivially yourself (unlike float copysign). Plus, if your only use for sign is for this range, why not just wrap that whole thing in a function and put it in your toolkit? def birange(start, stop): return range(start, stop, 1 if stop>=start else -1) Unlike using either sign or copysign, this doesn’t force the reader to stop and think about whether start==stop is safe, it will obviously safely give you an empty range. (You can extend this to be more flexible (take just stop, or start and stop, or start and stop and abs(step) arguments) if you need it.)