[Python-ideas] improvements to slicing

Raymond Hettinger raymond.hettinger at gmail.com
Wed Oct 6 22:35:39 CEST 2010

On Oct 6, 2010, at 12:21 PM, Ron Adam wrote:
> We don't need to change the current range function/generator to add inclusive or closed ranges.  Just add a closed_range() function to the itertools or math module.
>   [n for n in closed_range(-5, 5, 2)]  --> [-5, -3, -1, 1, 3, 5]

If I were a betting man, I would venture that you could post
a recipe for closed_range(), publicize it on various mailing
lists, mention it in talks, and find that it would almost never
get used.

There's nothing wrong with the idea, but the YAGNI factor
will be hard to overcome.  IMO, this would become cruft on 
the same day it gets added to the library.

OTOH for numerical applications, there is utility for a floating
point variant, something like linspace() in MATLAB.


More information about the Python-ideas mailing list