Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'objects,': 0.07; 'referring': 0.07; 'see.': 0.07; 'python': 0.09; '(1,': 0.09; '[])': 0.09; 'immutable': 0.09; 'objects.': 0.09; 'subject:while': 0.09; 'to:addr:comp.lang.python': 0.09; 'tuple': 0.09; 'tuple.': 0.09; 'cc:addr:python-list': 0.10; '(relatively': 0.16; '3],': 0.16; 'clear.': 0.16; 'confusion': 0.16; 'death.': 0.16; 'domains.': 0.16; 'foo()': 0.16; 'foo(object):': 0.16; 'ha!': 0.16; 'interpreting': 0.16; 'mutated': 0.16; 'naive': 0.16; 'permanently,': 0.16; 'stem': 0.16; 'tuples,': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'feb': 0.19; 'constant': 0.22; 'cc:2**0': 0.23; 'programming': 0.23; 'monday,': 0.23; 'statement': 0.23; 'cc:no real name:2**0': 0.24; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'expand': 0.26; '[1]': 0.27; 'expanding': 0.27; 'all.': 0.28; 'chris': 0.28; 'objects': 0.29; 'words': 0.29; 'class': 0.29; '(and': 0.32; '11,': 0.33; 'problem': 0.33; 'themselves': 0.33; 'changed': 0.34; 'received:google.com': 0.34; 'list': 0.35; 'from:addr:googlemail.com': 0.35; 'sequence': 0.35; 'pm,': 0.35; 'sometimes': 0.35; 'received:209.85': 0.35; 'list.': 0.35; 'add': 0.36; 'but': 0.36; '12,': 0.36; 'unable': 0.36; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'fact': 0.38; 'skip:" 10': 0.40; 'your': 0.60; 'back': 0.62; 'more': 0.63; 'eyes': 0.69; '2013': 0.84; 'harmony': 0.84; 'suspicion': 0.84; 'rick': 0.91; 'whereby': 0.91 X-Received: by 10.49.81.72 with SMTP id y8mr1400378qex.42.1360723422850; Tue, 12 Feb 2013 18:43:42 -0800 (PST) Newsgroups: comp.lang.python Date: Tue, 12 Feb 2013 18:43:42 -0800 (PST) In-Reply-To: <0c9bb6fd-b995-4a54-ba2e-4d446072a948@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw References: <86872ad2-fda0-403b-9f18-d1cb18e41860@t32g2000yqd.googlegroups.com> <50039290$0$29978$c3e8da3$5496439d@news.astraweb.com> <9309333c-13a0-464c-bd94-9c682363b8c9@googlegroups.com> <511516db$0$29969$c3e8da3$5496439d@news.astraweb.com> <62c3e7bb-d023-43b4-b759-f424707fd346@googlegroups.com> <75c82449-773e-4077-a6c9-e9cef08f845f@googlegroups.com> <13e5e306-d253-418e-a1b2-ac5bde03f07d@googlegroups.com> <5117868b$0$29998$c3e8da3$5496439d@news.astraweb.com> <375e9978-54a2-421a-a1fa-7f39cafc4f31@googlegroups.com> <43b37855-1d4d-4b16-ac83-115754bc9346@googlegroups.com> <0c9bb6fd-b995-4a54-ba2e-4d446072a948@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 123.192.32.215 MIME-Version: 1.0 Subject: Re: Implicit conversion to boolean in if and while statements 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.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 117 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360723431 news.xs4all.nl 6919 [2001:888:2000:d::a6]:40624 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38799 Rick Johnson=E6=96=BC 2013=E5=B9=B42=E6=9C=8813=E6=97=A5=E6=98=9F=E6=9C=9F= =E4=B8=89UTC+8=E4=B8=8A=E5=8D=881=E6=99=8248=E5=88=8607=E7=A7=92=E5=AF=AB= =E9=81=93=EF=BC=9A > On Monday, February 11, 2013 11:55:19 PM UTC-6, Chris Angelico wrote: >=20 > > On Tue, Feb 12, 2013 at 12:06 PM, 88888 Dihedral wrote: >=20 > > > A permanently mutated list is a tuple of constant objects. >=20 > > >=20 > > I nominate this line as "bemusing head-scratcher of the week". >=20 >=20 >=20 > Actually the statement is fact IF you can grok it through the eyes of cla= rity. >=20 >=20 >=20 > "A permanently mutated list..." >=20 >=20 >=20 > A list that has been mutated permanently, that is, it cannot be changed b= ack into a list. psst: i have a sneaking suspicion that he his referring to= tuples, let's see. >=20 >=20 >=20 > "...is a tuple..." >=20 >=20 >=20 > Ha! Well in Python the immutable sequence type /is/ a tuple after all. >=20 >=20 >=20 > "...of constant objects..." >=20 >=20 >=20 > The tuple contains objects, and it's objects will maintain a constant ord= ering (relatively in tuple structure) until until the tuple's death.=20 >=20 >=20 >>> a1=3D[1,2,3] >>> tuple1=3D(a1,4,5,6) >>> tuple1 ([1, 2, 3], 4, 5, 6) >>> a1=3D[1,2] >>> tuple1 ([1, 2, 3], 4, 5, 6) >>>=20 Yes, a tuple of constant objects is still not clear.=20 >=20 > Your confusion may stem from interpreting "constant" as the CS term "CONS= TANT"[1]; whereby the objects in the tuple are programming CONSTANTS, that = is, unable to change. But in reality, although a tuple (bka:StaticList) can= not expand to add more objects, or shrink to eject existing objects, the ob= jects themselves CAN change their own internal state WITHOUT disrupting the= immutable harmony of the tuple.=20 >=20 >=20 >=20 > Observe: >=20 > =20 >=20 > py> class Foo(object): >=20 > pass >=20 > py> foo =3D Foo() >=20 > py> t =3D (1,'1', foo) >=20 > py> t >=20 > (1, '1', <__main__.Foo object at 0x0267BF50>) >=20 > py> t[-1].bar =3D "abc" >=20 > py> t >=20 > (1, '1', <__main__.Foo object at 0x0267BF50>) >=20 >=20 >=20 > Or by expanding a list >=20 >=20 >=20 > py> t =3D (1,2,3) >=20 > py> t =3D t+([],) >=20 > py> t >=20 > (1, 2, 3, []) >=20 > py> t[-1].append('circus') >=20 > py> t >=20 > (1, 2, 3, ['circus']) >=20 >=20 >=20 > [1] Which is an unfortunate side-effect of polysemy and compounded expone= ntially by naive (and sometimes a purely malevolent intent when) transforma= tion of words into esoteric problem domains.