On Sat, Jul 3, 2010 at 4:54 AM, Robert William Hanks < astroultra...@gmail.com> wrote:
> 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 > Can you show me a case where it really is cumbersome. > >>> 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. > >>> aList[::2] [0, 2, 4, 6, 8] Which means you are doing [0, 2, 4, 6, 8] = None, which is plain and simple - wrong. How will you define the legitimacy of this statement. What you are basically doing here is,, >>> [None]*len(aList[::2]) [None, None, None, None, None] >>> aList[::2] [0, 2, 4, 6, 8] Setting [0, 2, 4, 6, 8] to [None, None, None, None, None], thereby operating on two similar data structure (here list) > Just want some feedback. > Just my thoughts. ~l0nwlf
-- http://mail.python.org/mailman/listinfo/python-list