Questions regarding design decisions in listobject.c

jepler epler jepler.lnk at lnk.ispi.net
Tue Jun 6 07:50:54 EDT 2000


>Thomas Wouters wrote:
>> Actually, it's very intuitive, if you see the start and end index of the
>> slice not as items, but as the gaps between the items.
>
On Sun, 04 Jun 2000 21:26:07 GMT, Courageous
 <jkraska1 at san.rr.com> wrote:
>Well, yeah, but [0:3] as "element zero through three, inclusive"
>is about as intuitive as you can get. While I understand completely
>how the current implementation works (reading the source code and
>all, dontcha know), I still fail to see *why* this was chosen.
>I'm presuming there must be some conditions where this particular
>idiom was required or caused for nasty syntactic transformations
>if it wasn't used?

If it wasn't written in this way how would you express the use of a slice
to insert items:
	>>> s = [1,2,3,4,5]
	>>> s[3:3] = ["hi there mom"]
	>>> print s
	[1, 2, 3, 'hi there mom', 4, 5]

Jeff



More information about the Python-list mailing list