Slicing beyond list -- bug or featurette?

William Tanksley William.Tanksley at p98.f112.n480.z2.fidonet.org
Fri Jul 2 20:00:32 EDT 1999


From: wtanksle at dolphin.openprojects.net (William Tanksley)

On Fri, 2 Jul 1999 22:22:10 GMT, Ivan Van Laningham wrote:
>Hi All--

>Pierre Fortin wrote:

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

>[bobbitt]

>> 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

>I don't presume to speak for Guido, but the way slicing is implemented
>it seems likely that you can count on it: list[:] is implemented as if

Furthermore, this makes fundamental sense -- an array reference is defined
to return the item stored at that location.  A slice is defined to return
a list containing the items within those locations.

An empty list is still a list; an item that doesn't exist, however, is
hard to return.

><but-they-don't-call-him-guido-svetz-for-nothing>-ly y'rs,
>Ivan;-)

We-have-VAYS-of-justifying-vhat-we-vant-ly y'rs,

-- 
-William "Billy" Tanksley




More information about the Python-list mailing list