[Python-Dev] range objects in 3.x

Ethan Furman ethan at stoneleaf.us
Tue Sep 27 18:06:55 CEST 2011


Raymond Hettinger wrote:
> 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)    

I like the numpoints option.

I also like Alexander's idea of making this new range able to work with 
other types that support addition/division -- but in that case does the 
'f' prefix still make sense?

~Ethan~


More information about the Python-Dev mailing list