
Dec. 31, 2012
5:38 a.m.
On 12/30/2012 10:47 PM, Nick Coghlan wrote:
The problem is bytearray, not bytes and str.
bytearray is a builtin mutable sequence with a non-destructive replace() method. It doesn't matter that this is almost certainly just a mistake due to its immutable bytes heritage, the presence of that method is enough to categorically rule out the idea of adding a destructive replace() method to mutable sequences in general.
All this discussion is, of course, before getting into the fact that string, bytes, and bytearray .replace() methods all work on subsequences rather than elements.