<br><br><div><span class="gmail_quote">On 10/15/07, <b class="gmail_sendername">Terry Reedy</b> <<a href="mailto:email@example.com">firstname.lastname@example.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>"Guido van Rossum" <<a href="mailto:email@example.com">firstname.lastname@example.org</a>> wrote in message<br>news:email@example.com...<br>| > > > As I work on these.. Should the mutable PyBytes_ (buffer) objects
<br>implement<br>| > > > the following methods inplace and return an additional reference to<br>self?<br>| ><br>| > > > .capitalize(), .center(), .expandtabs(), .rjust(), .swapcase(),<br>.title(),<br>
| > > > .upper(), .zfill()<br>| ><br>| > > No... That would be a huge trap to fall in at all sorts of occasions.<br><br>At this point, I though your objection was to returning the buffer instead<br>of None, as with list mutations, and for the same reason. But admittedly,
<br>some people do not like this feature of lists.<br><br>| > So would returning a different object. I expect a mutation operation<br>| > on an explicitly mutable object to mutate the object, instead of<br>| > creating something new.
<br><br>So was I.<br><br>| Since these methods with these very names already exist for strings<br>| and return new values there, I don't see the gotcha unless you never<br>| use strings.<br><br>The real question is what is more useful? I would think that being able to
<br>edit in place would be a reason to use a buffer rather than (immutable)<br>bytes.<br><br>tjr</blockquote><div><br>I agree, thats a benefit of a mutable object. But I think the point about not reusing the names with a different behavior is valid so that some code can be written to operate on objects with duck type without having to know if its mutable or not.