Why Python does *SLICING* the way it does??

Antoon Pardon apardon at forel.vub.ac.be
Thu Apr 21 02:28:42 EDT 2005


Op 2005-04-20, Bill Mill schreef <bill.mill at gmail.com>:
> On 20 Apr 2005 13:39:42 GMT, Antoon Pardon <apardon at forel.vub.ac.be> wrote:
>> Op 2005-04-20, Bill Mill schreef <bill.mill at gmail.com>:
>> 
>> You write this af if other solutions can't be consistent.
>
> Propose one, and I won't write it off without thinking, but my bias is
> way against it from experience. Knowledge gets scattered across the
> program,

Knowledge always gets scattered across the program. The end
index can vary endlessly but that doesn't seem to worry
you. So why is a varying start index so worrysome?

> unless you're defining the start index every time you use the
> list, which seems no better than adding an offset to me.

I don't see why the start index can't be accessible through
a method or function just like the length of a list is now.

My favourite would be a range method so we would have
the following idiom:

  for i in lst.range():
    do something with lst[i]



More information about the Python-list mailing list