title: What is the motivation behind python's choice for interpretation of list indexing reassignment?
body: <p>I am new to python (using python2.7) and I don't understand the below behavior when updating lists by indexes and what design choices motivate the behavior. I am used to working with R which has quite a different default behavior. Also is this specific to lists or will this happen with any mutable sequence? What about with arrays?</p>
  
  <p>If I define a list and want to reassign values in the list I am confused by some of the behavior </p>
  
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; l = list(range(10))
  &gt;&gt;&gt; l[2:4] = [20, 30] # expected
  &gt;&gt;&gt; l                                                                           
  [0, 1, 20, 30, 4, 5, 6, 7, 8, 9]                                                                          
  &gt;&gt;&gt; l[2] = [20, 30]   # expected
  &gt;&gt;&gt; l 
  [0, 1, [20, 30], 30, 4, 5, 6, 7, 8, 9]                                                                      
  
  # replacement length is longer than given index range, ignores end of given range on left side
  &gt;&gt;&gt; l = list(range(10))
  &gt;&gt;&gt; l[2:3] = [20, 30, 40]  # behaves as l[2:5]=[20,30,40] (unexpected)
  &gt;&gt;&gt; l
  [0, 1, 20, 30, 40, 3, 4, 5, 6, 7, 8, 9] 
  
  # replacement length is shorter than given index range, deletes unused index/values on left side
  &gt;&gt;&gt; l = list(range(10))
  &gt;&gt;&gt; l[2:9] = [20, 30, 40] # len(l)=6 (unexpected)
  &gt;&gt;&gt; l
  [0, 1, 20, 30, 40, 9] 
  
  # replacement length is longer than given range and outside of current length, appends to list.
  &gt;&gt;&gt; l = list(range(10))
  &gt;&gt;&gt; l[9:len(l)] = [20, 30, 40] # last value changed, len(l)= 12 (unexpected)
  &gt;&gt;&gt; l
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 20, 30, 40]
  </code></pre>
  
  <p>In R (3.2.3) the behavior is as follows (note, R uses 1 as first index and includes last index such that 2:3 is python's 2:4)</p>
  
  <pre><code>&gt; l = 0:9
  &gt; l[2:3] = c(20, 30)
  &gt; l
   [1]  0 20 30  3  4  5  6  7  8  9
  # replacement length is longer than given index range, values beyond given index range are ignored
  &gt; l = 0:9
  &gt; l[2] = c(20, 30)
  Warning message:
  In l[2] = c(20, 30) :
    number of items to replace is not a multiple of replacement length
  &gt; l
   [1]  0 20 2  3  4  5  6  7  8  9
  
  
  # replacement length is longer than given index range, values beyond given index range are ignored
  &gt; l = 0:9
  &gt; l[2:3] = c(20, 30, 40)
  Warning message:
  In l[2:3] = c(20, 30, 40) :
    number of items to replace is not a multiple of replacement length
  &gt; l
   [1]  0 20 30  3  4  5  6  7  8  9
  
  # replacement length is shorter than given index range, values repeated until index range is met
  &gt; l[2:9] = c(20,30,40)
  &gt; l
   [1]  0 20 30 40 20 30 40 20 30 9
  
  # replacement length is longer than given index range, values beyond given index range are ignored
  &gt; l = 0:9
  &gt; l[9:length(l)] = c(20,30,40)
  Warning message:
  In l[9:length(l)] = c(20, 30, 40) :
    number of items to replace is not a multiple of replacement length
  &gt; l
   [1]  0  1  2  3  4  5  6  7 20 30
  </code></pre>
  
  <p>So in short, R assumes that the range given on the left side is more trustworthy than on the right side and either ignores or repeats values on the right to satisfy the left side of the assignment.</p>
  
  <p>But what exactly is Python doing?</p>