Slicing beyond list -- bug or featurette?

Pierre Fortin pfortin at cisco.com
Fri Jul 2 16:38:34 EDT 1999


Just ran into a situation which can be summarized as follows:

list = [ 0,1,2,3,4 ]

list[<0..4>] returns the appropriate item

list[m] where m is >= len(list) expectedly fails

list[2:50] returns [ 2,3,4 ]
list[20:] or list[20:30] returns []
 
Can I count on this, or should I code try/except for the day it's
fixed?  This 'feature' reduces the error situations; but is it
correct/intended?

Curious,
Pierre
--
Linux -- The C(r)ash-Free Operating System




More information about the Python-list mailing list