Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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; '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; '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; '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; '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; 'whereby': 0.91 X-Received: by 10.49.81.72 with SMTP id y8mr1327155qex.42.1360691287439; Tue, 12 Feb 2013 09:48:07 -0800 (PST) Newsgroups: comp.lang.python Date: Tue, 12 Feb 2013 09:48:07 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=70.196.110.134; posting-account=h3aEwQoAAACiuqX-oR3gvCVFm8lLHoWj 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> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 70.196.110.134 MIME-Version: 1.0 Subject: Re: Implicit conversion to boolean in if and while statements From: Rick Johnson To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 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: 56 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360694030 news.xs4all.nl 6929 [2001:888:2000:d::a6]:34346 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38777 On Monday, February 11, 2013 11:55:19 PM UTC-6, Chris Angelico wrote: > On Tue, Feb 12, 2013 at 12:06 PM, 88888 Dihedral wrote: > > A permanently mutated list is a tuple of constant objects. > > I nominate this line as "bemusing head-scratcher of the week". Actually the statement is fact IF you can grok it through the eyes of clari= ty. "A permanently mutated list..." A list that has been mutated permanently, that is, it cannot be changed bac= k into a list. psst: i have a sneaking suspicion that he his referring to t= uples, let's see. "...is a tuple..." Ha! Well in Python the immutable sequence type /is/ a tuple after all. "...of constant objects..." The tuple contains objects, and it's objects will maintain a constant order= ing (relatively in tuple structure) until until the tuple's death.=20 Your confusion may stem from interpreting "constant" as the CS term "CONSTA= NT"[1]; whereby the objects in the tuple are programming CONSTANTS, that is= , unable to change. But in reality, although a tuple (bka:StaticList) canno= t expand to add more objects, or shrink to eject existing objects, the obje= cts themselves CAN change their own internal state WITHOUT disrupting the i= mmutable harmony of the tuple.=20 Observe: =20 py> class Foo(object): pass py> foo =3D Foo() py> t =3D (1,'1', foo) py> t (1, '1', <__main__.Foo object at 0x0267BF50>) py> t[-1].bar =3D "abc" py> t (1, '1', <__main__.Foo object at 0x0267BF50>) Or by expanding a list py> t =3D (1,2,3) py> t =3D t+([],) py> t (1, 2, 3, []) py> t[-1].append('circus') py> t (1, 2, 3, ['circus']) [1] Which is an unfortunate side-effect of polysemy and compounded exponent= ially by naive (and sometimes a purely malevolent intent when) transformati= on of words into esoteric problem domains.