[Chicago] List revolution

Frank Duncan herbieman2000 at gmail.com
Sat Sep 10 17:27:30 CEST 2011

I foresee a lot of off by one errors :P

Though there are good reasons to start at zero.  Here is one:

Consider two lists, one twice the size of the other, and you'd like to
match up either the first list with 2*idx or 2*idx + 1 of the second.
It becomes very cumbersome to do so if you don't start at zero.

A more common example of this, for me, is doing layout design.  I have
a list of X widgets, each Y wide, that I'd like to position on the
screen.  I simply keep track of the index and do X*Y*idx to find the
correct lefthand placement.  Imagine if we started pixel placement at
1 (because pixels on the screen are just a list too, right?  why make
the leftmost pixel be zero when counting things should start at 1?)

So I'd have to do X * Y * (idx - 1) + 1

That seems odd to me.

The fact is that zero plays very well with multiplication and addition
when talking about placement.  One does not play so well.

On Sat, Sep 10, 2011 at 10:15 AM, Sal Lara <sal at spoton.com> wrote:
> I think it's super-overdue. I honestly can't even think of that many places
> in my code where I depend on the actual numerical index value of a list
> element. That in and of itself isn't very pythonic, right? However, were the
> first list element actually 1, many who answer yes to my question might feel
> differently.
> -Sal
> On Sat, Sep 10, 2011 at 10:03 AM, Tathagata Dasgupta <tathagatadg at gmail.com>
> wrote:
>> What do guys think of list revolution?
>> http://mail.python.org/pipermail/python-ideas/2011-September/011448.html
>> --
>> Cheers,
>> T
>> _______________________________________________
>> Chicago mailing list
>> Chicago at python.org
>> http://mail.python.org/mailman/listinfo/chicago
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago

More information about the Chicago mailing list