Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'modify': 0.07; '[1]:': 0.09; '[2]:': 0.09; '[3]:': 0.09; 'interpreted': 0.09; 'lawrence': 0.09; "'a',": 0.16; '[4]:': 0.16; 'client:': 0.16; 'concatenate': 0.16; 'iterable': 0.16; 'last)': 0.16; 'mylist': 0.16; 'sequence:': 0.16; 'tuple.': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; '(not': 0.18; 'looked': 0.18; 'header:User-Agent:1': 0.23; 'string,': 0.24; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; '+0100,': 0.31; '(most': 0.33; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'consistent': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'recent': 0.39; 'expect': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'kind': 0.63; 'mar': 0.68; '"spam"': 0.84; "'2',": 0.84; 'albert': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=39kDJ6hwn/giZCZdewpMLvM0mz1EzZON2HltsFHUNg4=; b=IZfleCNJ+MEW6GdU7KAtW6o4Xl71xXfd6Sa3dkqFkC8Jv8NPUkc1B357g0Sq5YsarR 4Fk624U+9RE9E1euPHufafkPxZTXOtcxpE2tEKvtHcH7tkdolPt8GCAn8R5i6UrmJllE WgmQ7DLp66jQvw0MgSaua635qXKEyZ7o94gGA3GGIMuR4YCN08yZBcCUb8VePIrhSH4j P3T2k/uwZ9HMHx4mgKYL0A7/S5cAtb03maqllUbMsUcIky7HpQh+IaL16QvSr+0eIBLv mww0XaTh5qolT+uXLGTTjgSEtR23+jZcD8070zOuTQsIg8IXSFJngvdHhrbM8p5qBACI 7MlQ== X-Received: by 10.14.94.3 with SMTP id m3mr33805503eef.54.1393771066738; Sun, 02 Mar 2014 06:37:46 -0800 (PST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: python-list@python.org Subject: Re: Tuples and immutability References: <059a3d10-453a-40fd-99f9-33ceb8ecabf7@googlegroups.com> <889d371a-c8e3-4d6b-8ba4-d3df61f29b0d@googlegroups.com> Date: Sun, 02 Mar 2014 15:37:44 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable From: "albert visser" In-Reply-To: User-Agent: Opera Mail/12.16 (Linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 51 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393771074 news.xs4all.nl 2846 [2001:888:2000:d::a6]:50056 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!news.franciliens.net!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:67444 On Sun, 02 Mar 2014 15:17:11 +0100, Eric Jacoboni = wrote: > Le 02/03/2014 15:05, Mark Lawrence a =C3=A9crit : > >> The behaviour is consistent except when you try to modify a tuple. >> > > Not in my opinion... > > li =3D [10, 30] > li =3D li + "spam" --> TypeError: can only concatenate list (not "st= r") > li +=3D "spam" --> Ok > possibly because you expect +=3D to take "spam" as a string, but have yo= u = looked at the result? In [1]: mylist =3D ['1', '2'] In [2]: mylist +=3D 'spam' In [3]: mylist Out[3]: ['1', '2', 's', 'p', 'a', 'm'] consequently, try adding something that can not be interpreted as a = sequence: In [4]: mylist +=3D 3 ------------------------------------------------------------------------= --- TypeError Traceback (most recent call la= st) in () ----> 1 mylist +=3D 3 TypeError: 'int' object is not iterable -- = Vriendelijke groeten / Kind regards, Albert Visser Using Opera's mail client: http://www.opera.com/mail/