A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-October/009977.html below:

[Python-Dev] Wierd buffer "add" behaviour.

[Python-Dev] Wierd buffer "add" behaviour.M.-A. Lemburg mal@lemburg.com
Mon, 16 Oct 2000 19:42:15 +0200
Greg Stein wrote:
> 
> On Mon, Oct 16, 2000 at 09:50:22AM +0200, M.-A. Lemburg wrote:
> > Mark Hammond wrote:
> >...
> > > This yields the following strange behaviour:
> > >
> > > >>> a=buffer('a')
> > > >>> a+a
> > > 'aa'
> > > >>> a+a+a
> > > Traceback (innermost last):
> > >   File "<interactive input>", line 1, in ?
> > > TypeError: cannot add type "buffer" to string
> > > >>>
> > >
> > > That doesnt seem correct to me?
> >
> > Neither to me.
> 
> It is caused by the non-commutative aspect of Python types. You end up with
> a string, and that type doesn't know how to add a buffer to itself.

The problem is that buffer() objects coerce to strings in the
first place... they should return new buffer objects instead
of strings -- then we wouldn't have the above problems.
 
> ... 
> Of course, the choice of returning a string (from buf+buf) rather than a
> buffer was arguably the wrong choice.

Right :-/

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4