Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'operator': 0.04; '>>>>': 0.09; 'reply-to:addr:comp.lang.python': 0.09; 'to:addr:comp.lang.python': 0.09; '~ethan~': 0.09; 'cc:addr :python-list': 0.15; "'w',": 0.16; 'imo,': 0.16; 'operands': 0.16; 'subject:copy': 0.16; 'succeed,': 0.16; 'wrote:': 0.16; 'example.': 0.18; 'possibly': 0.19; '(most': 0.21; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'traceback': 0.24; 'cc:2**0': 0.25; 'cc:addr:python.org': 0.29; 'typeerror:': 0.30; 'does': 0.32; 'list': 0.32; 'header:User-Agent:1': 0.33; 'object': 0.33; 'there': 0.33; 'from:addr:googlemail.com': 0.34; 'normally': 0.34; 'assignment': 0.34; 'last):': 0.34; '(not': 0.34; 'received:209.85.160': 0.35; 'file': 0.35; 'two': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'steven': 0.38; 'received:209.85': 0.38; 'should': 0.38; 'either': 0.39; 'received:209': 0.39; 'subject:: ': 0.39; 'types': 0.61; 'header :Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'reply- to:addr:googlegroups.com': 0.74; 'subject:write': 0.84; '-->': 0.91; 'skip:2 50': 0.91 Newsgroups: comp.lang.python Date: Fri, 13 Jan 2012 14:26:09 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=1.168.135.149; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> User-Agent: G2/1.0 X-Google-Web-Client: true MIME-Version: 1.0 Subject: Re: copy on write From: 88888 Dihedral To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: comp.lang.python@googlegroups.com List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326493579 news.xs4all.nl 6885 [2001:888:2000:d::a6]:39349 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18951 Ethan Furman=E6=96=BC 2012=E5=B9=B41=E6=9C=8814=E6=97=A5=E6=98=9F=E6=9C=9F= =E5=85=ADUTC+8=E4=B8=8A=E5=8D=882=E6=99=8240=E5=88=8647=E7=A7=92=E5=AF=AB= =E9=81=93=EF=BC=9A > Steven D'Aprano wrote: > > Normally this is harmless, but there is one interesting little glitch y= ou=20 > > can get: > >=20 > >>>> t =3D ('a', [23]) > >>>> t[1] +=3D [42] > > Traceback (most recent call last): > > File "", line 1, in > > TypeError: 'tuple' object does not support item assignment > >>>> t > > ('a', [23, 42]) >=20 >=20 > There is one other glitch, and possibly my only complaint: >=20 > --> a =3D [1, 2, 3] > --> b =3D 'hello, world' > --> a =3D a + b > Traceback (most recent call last): > File "", line 1, in > TypeError: can only concatenate list (not "str") to list > --> a +=3D b > --> a > [1, 2, 3, 'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'] >=20 > IMO, either both + and +=3D should succeed, or both should fail. >=20 > ~Ethan~ The +=3D operator is not only for value types in the above example.=20 =20 An operator of two operands and an operator of three operands of=20 general object types are two different operators.=20