List replication operator

Alan Bawden alan at csail.mit.edu
Sun May 27 02:28:50 EDT 2018


If the behaviour of * on a sequence is confusing, then isn't the following
behaviour also confusing for exactly the same reason?

   >>> a = [[]]
   >>> b = a + a
   >>> b
   [[], []]
   >>> b[0].append(5)
   >>> b
   [[5], [5]]

And if so, shouldn't there also be a concatenation operator that performs
a copy of some kind on its operands?

-- 
Alan Bawden



More information about the Python-list mailing list