Op 2005-04-20, Roy Smith schreef <[EMAIL PROTECTED]>: > Antoon Pardon <[EMAIL PROTECTED]> wrote: >>Op 2005-04-20, Roy Smith schreef <[EMAIL PROTECTED]>: >>> Antoon Pardon <[EMAIL PROTECTED]> wrote: >>> >>>> Personnaly I would like to have the choice. Sometimes I prefer to >>>> start at 0, sometimes at 1 and other times at -13 or +7. >>> >>> Argggh. Having two (or more!) ways to do it, would mean that every time I >>> read somebody else's code, I would have to figure out which flavor they are >>> using before I could understand what their code meant. That would be evil. >> >>This is nonsens. table[i] = j, just associates value j with key i. >>That is the same independend from whether the keys can start from >>0 or some other value. Do you also consider it more ways because >>the keys can end in different values? > > There are certainly many examples where the specific value of the > first key makes no difference. A good example would be > > for element in myList: > print element > > On the other hand, what output does > > myList = ["spam", "eggs", "bacon"] > print myList[1] > > produce? In a language where some lists start with 0 and some start > with 1, I don't have enough information just by looking at the above > code.
Yes you have. The fact that a language allows a choice doesn't contradict there is a default, when no choice is specified. My preference would be that it would produce "spam", because if you want the *first*" element, you want the element associated withe the key 1. Or maybe the language would force you to give a start index, so that you would have to write: MyList = [3 -> "spam", "eggs", "bacon"] End of course the language would provide instances or methods so you could ask what the first index was. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list