Why Python does *SLICING* the way it does??
Roy Smith
roy at panix.com
Wed Apr 20 10:39:28 EDT 2005
Antoon Pardon <apardon at forel.vub.ac.be> wrote:
>Op 2005-04-20, Roy Smith schreef <roy at panix.com>:
>> Antoon Pardon <apardon at forel.vub.ac.be> 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.
More information about the Python-list
mailing list