[Python-Dev] range objects in 3.x

Raymond Hettinger raymond.hettinger at gmail.com
Tue Sep 27 17:44:56 CEST 2011


On Sep 27, 2011, at 11:24 AM, Ethan Furman wrote:

> Alexander Belopolsky wrote:
>> On Tue, Sep 27, 2011 at 2:23 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>> ..
>>> And I don't like "linspace" either. Something more self
>>> explanatory such as "subdivide" or "interpolate" might
>>> be better.
>> "Grid" would be nice and short, but may suggest 2-dimentional result.
>> Whatever word we choose, I think it should be a noun rather than a
>> verb.  ("Comb" (noun) brings up the right image, but is probably too
>> informal  and may be confused with a short for "combination.")
> 
> segment?  srange?

In the math module, we used an f prefix to differentiate math.fsum() from the built-in sum() function.  That suggests frange() as a possible name for a variant of range() that creates floats.

That works reasonably well if the default argument pattern is the same as range:   frange(10.0, 20.0, 0.5)

There could be an optional argument to compute the interval:   frange(10.0, 20.0, numpoints=20)

And possibly a option to include both endpoints:  frange(10.0, 20.0, 0.5, inclusive=True)    


Raymond


More information about the Python-Dev mailing list