Add vs in-place add of str to list

rs387 rstarkov at gmail.com
Thu Oct 2 11:11:53 EDT 2008


On Oct 2, 3:50 pm, Mel <mwil... at the-wire.com> wrote:
> rs387 wrote:
> > I see. Do you know whether this is seen as a problem with the language
> > design?
>
> No.

OK, I get it now. I was assuming that the "+" could be implemented in
terms of "+=" as follows:

def add(x,y):
    temp = list(x)
    temp += y
    return temp

But it turns out that this is not what "+" means at all. A bit of a
gotcha...

Roman



More information about the Python-list mailing list