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

seberino at spawar.navy.mil seberino at spawar.navy.mil
Wed Apr 20 01:58:49 EDT 2005


Many people I know ask why Python does slicing the way it does.....

Can anyone /please/ give me a good defense/justification???

I'm referring to why mystring[:4] gives me
elements 0, 1, 2 and 3 but *NOT* mystring[4] (5th element).

Many people don't like idea that 5th element is not invited.

(BTW, yes I'm aware of the explanation where slicing
is shown to involve slices _between_ elements.  This
doesn't explain why this is *best* way to do it.)

Chris




More information about the Python-list mailing list