newbie string question
Mike C. Fletcher
mcfletch at rogers.com
Fri Jun 21 00:19:52 EDT 2002
pystr[3:]
is equivalent to:
pystr[3:len(pystr)]
and
pystr[:3]
is equivalent to:
pystr[0:3]
That is, when you leave off a slice index, the "end of the sequence in
that direction" is used. Thus:
pystr[ : ]
is:
pystr[0:len(pystr)]
HTH,
Mike
Don Low wrote:
...
> So if I understand, pystr[3] refers to the subscript index, but pystr[3:]
> refers to the slice index. pystr[2:5] means slice at slice index 2 and 5,
> not start at subscript index 2 and slice at slice index 5.
>
> I just want to understand this once and for all.
_______________________________________
Mike C. Fletcher
http://members.rogers.com/mcfletch/
More information about the Python-list
mailing list