[Python-3000] PEP 3137 plan of attack
Jim Jewett
jimjjewett at gmail.com
Mon Oct 15 15:57:20 CEST 2007
On 10/12/07, Guido van Rossum <guido at python.org> wrote:
> On 10/12/07, Gregory P. Smith <greg at krypto.org> 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
More information about the Python-3000
mailing list