On Sun, Dec 30, 2012 at 5:58 PM, MRAB <python@mrabarnett.plus.com> wrote:
On 2012-12-30 16:00, Ned Batchelder wrote:
I don't understand the conflict?  .replace() from sequence does
precisely the same thing as .replace() from bytes if you limit the
arguments to single-byte values.  It seems perfectly natural to me. I
must be missing something.

[snip]
The difference is that for bytes and str it returns the result (they
are immutable after all), but the suggested addition would mutate the
list in-place. In order to be consistent it would have to return the
result instead.
 
I don't think that consistency between str and list is desirable. If .index for example were consistent in str and list it would look like this:

    [9, 8, 7, 6, 5].index([8,7]) # = 1

Also, 
    reversed, sorted (copy)
    list.reverse, list.sort (in-place)
From that perspective list.replace working in-place *is* consistent.

However, I can see that this '.replace' might cause more confusion than future code clarity.

What about .indices though?