why python don't support "extended slice direct assignment" for lists?

Robert William Hanks astroultraman at gmail.com
Fri Jul 2 19:24:43 EDT 2010


why pure python don't support "extended slice direct assignment" for lists?

today we have to write like this,

>>> aList=[0,1,2,3,4,5,6,7,8,9]
>>> aList
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> aList[::2]= [None]*len(aList[::2])  #or do the math by hand, what's not
always possible
>>> aList
[None, 1, None, 3, None, 5, None, 7, None, 9]

why not accept syntax like this for extended slice

aList[::2] = None

when let's say, the left side is a list and the right side is bool, int or
float.
the laborious [nunber]*len(aList[::2]) seens to me less readable when you
want to set lost of items of a list to the same number.
Also correct me if i am wrong, calling len() and building a list to this
kind of operation seems a waste.

Just want some feedback.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100702/80c7d2d4/attachment.html>


More information about the Python-list mailing list