Slice confusion : a[n:p] is a list exclude the last element p

nguyen khanh phuoc-khanh.nguyen at bull.net
Mon Apr 28 14:25:26 CEST 2003


a=range(10)
b=a[3:7]
b=[3,4,5,6]
Why the design exclude the last element ?
I's because the distinction of "element and list-element" ?
a[3]=3        # element
a[3:4]=[3]   # list-element

Why the designer d'nt use a[3:3]=[3] instead of a[p:p]=[] ?
The result a[p:p]=[] for all p d'nt add new information ,
The design a[n:p] clarify the mind to include the last element p .
and a[p:p]=[p] is very clear and dinctint from a[p]=p .

Thank to advise me your idea about the circus-slice notion .
Faithfull .
A Pythonian construct .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20030428/5a32ed6b/attachment.html>


More information about the Python-list mailing list