A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2011-September/113690.html below:

[Python-Dev] range objects in 3.x

[Python-Dev] range objects in 3.xSteven D'Aprano steve at pearwood.info
Tue Sep 27 19:55:15 CEST 2011
Ethan Furman wrote:

> What about the idea of this signature?
> 
> frange([start], stop, step=None, count=None)
> 
> Then when count is desired, it can be specified, and when step is 
> sufficient, no change is necessary.

A default of start=0 makes sense for integer range, because the most 
common use for range *by far* is for counting, and in Python we count 0, 
1, 2, ... Similarly, we usually count every item, so a default step of 1 
is useful.

But for numeric work, neither of those defaults are useful. This 
proposed spread/frange/whatever function will be used for generating a 
sequence of equally spaced numbers, and not for counting. A starting 
value of 0.0 is generally no more special than any other starting value. 
There is no good reason to single out default start=0. Likewise a 
step-size of 1.0 is also arbitrary.

It isn't useful to hammer the square peg of numeric ranges into the 
round hole of integer counts. We should not try to force this float 
range to use the same API as builtin range.

(In hindsight, it is a shame that range is called "range" instead of 
"count". itertools got the name right.)



-- 
Steven

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4