[Python-ideas] Inclusive Range

Jim Jewett jimjjewett at gmail.com
Wed Oct 6 15:18:08 CEST 2010


On 10/5/10, C. Titus Brown <ctb at msu.edu> wrote:
> On Tue, Oct 05, 2010 at 02:07:41PM +0100, Michael Foord wrote:

>> It is *good* that range(5) produces 5 values (0 to 4)

If not for compatibility, the 5 values (1,2,3,4,5) would be even
better.  But even in a new language, changing the rest of the language
so that (1,2,3,4,5) was more useful might not be a win.

> Doesn't it make sense that ... for i in range(5):
> mimics the C/C++ behavior of    for (i = 0; i < 5; i++)

If not for assumed familiarity with C idioms, why shouldn't it instead match
    for (i=1; i<=5; i++)

-jJ



More information about the Python-ideas mailing list