On 10/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> On 10/12/07, Gregory P. Smith <[EMAIL PROTECTED]> wrote:
> > > > - add missing methods to PyBytes (for list, see the PEP and compare to
> > > > what's already there)

> > As I work on these..  Should the mutable PyBytes_ (buffer) objects implement
> > the following methods inplace and return an additional reference to self?

> > .capitalize(), .center(), .expandtabs(), .rjust(), .swapcase(), .title(),
> > .upper(), .zfill()

> No... That would be a huge trap to fall in at all sorts of occasions.

So would returning a different object.  I expect a mutation operation
on an explicitly mutable object to mutate the object, instead of
creating something new.

If it returns a new one, I can imagine doing something like:

    obj.inqueue=bytesbuffer(100)
    obj.inqueue.lower()   # oh, wait, that didn't really do anything
after all...
    if obj.inqueue[:4] == b"http":   # works on my *regular* input...

Maybe the answer is "don't do that", and to only do this sort of
processing before it goes in the buffer or after it comes out, but ...
it still looks like a major gotcha.

-jJ
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to