Re: [Tutor] append string

2008-03-22 Thread Dave Kuhlman
On Sat, Mar 22, 2008 at 09:46:58AM +0100, Andreas Kostyrka wrote: > > Basically, strings are immutable. If you need to append something to a > string, you need to construct a new string object with the new value. > > Now if you are using this to collect huge outputfiles in pieces, one of > the c

Re: [Tutor] append string

2008-03-22 Thread Andreas Kostyrka
somestring = "ABC" somestring2 = somestring + "D" somestring2 += "EF" assert somestring2 == "ABCDEF" assert somestring == "ABC" assert id(somestring) != id(somestring2) Basically, strings are immutable. If you need to append something to a string, you need to construct a new string object with th

Re: [Tutor] append string

2008-03-21 Thread Tom Tucker
Strings are immutable, you can't append to them. How about this >>> mystring = 'Elis' >>> mystring.append('Aeris') Traceback (most recent call last): File "", line 1, in AttributeError: 'str' object has no attribute 'append' >>> mystring + ' Aeris' 'Elis Aeris' >>> x = mystring + ' Aeri