Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'type,': 0.07; 'python': 0.09; 'dict': 0.09; 'literal': 0.09; 'objects.': 0.09; 'subject:while': 0.09; 'to:addr:comp.lang.python': 0.09; 'tuple': 0.09; 'cc:addr:python-list': 0.10; 'char"': 0.16; 'clash': 0.16; 'declaration': 0.16; 'dictionaries': 0.16; 'efficiently.': 0.16; 'expressions.': 0.16; 'for,': 0.16; 'iterated': 0.16; 'literals': 0.16; 'mutated': 0.16; 'nesting': 0.16; 'purposes.': 0.16; 'syntax.': 0.16; 'thread.': 0.16; 'tuple,': 0.16; 'tuples,': 0.16; 'wrote:': 0.17; 'proposed': 0.20; 'sort': 0.21; 'earlier': 0.21; 'constant': 0.22; 'parse': 0.22; 'tuples': 0.22; 'cc:2**0': 0.23; 'elements': 0.23; 'monday,': 0.23; 'this:': 0.23; 'cc:no real name:2**0': 0.24; "we'd": 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'easiest': 0.27; 'this?': 0.28; 'chris': 0.28; 'fine': 0.28; 'depth': 0.29; 'grouping': 0.29; 'function': 0.30; 'could': 0.32; '11,': 0.33; 'like:': 0.33; 'operations': 0.33; 'received:google.com': 0.34; '(1)': 0.34; 'list': 0.35; 'from:addr:googlemail.com': 0.35; 'doing': 0.35; 'something': 0.35; 'but': 0.36; 'useful': 0.36; 'too': 0.36; 'does': 0.37; 'far': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'list,': 0.39; 'short': 0.39; 'where': 0.40; 'end': 0.40; 'side': 0.61; 'more': 0.63; '2013': 0.84; 'call!': 0.84; 'confusing': 0.84; 'pike': 0.84; 'vehemently': 0.84; 'rick': 0.91; 'poorly': 0.93 X-Received: by 10.49.71.135 with SMTP id v7mr1185811qeu.28.1360631178569; Mon, 11 Feb 2013 17:06:18 -0800 (PST) Newsgroups: comp.lang.python Date: Mon, 11 Feb 2013 17:06:18 -0800 (PST) In-Reply-To: <43b37855-1d4d-4b16-ac83-115754bc9346@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> 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: 108 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360631186 news.xs4all.nl 6943 [2001:888:2000:d::a6]:44544 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38713 Rick Johnson=E6=96=BC 2013=E5=B9=B42=E6=9C=8811=E6=97=A5=E6=98=9F=E6=9C=9F= =E4=B8=80UTC+8=E4=B8=8B=E5=8D=889=E6=99=8213=E5=88=8658=E7=A7=92=E5=AF=AB= =E9=81=93=EF=BC=9A > On Monday, February 11, 2013 6:40:23 AM UTC-6, Chris Angelico wrote: >=20 > > [...] >=20 > > Or doing what you were pointing and laughing at Pike for, and using >=20 > > two-symbol delimiters. You could even make it majorly logical: >=20 > >=20 >=20 > > list_ =3D [[ 1, 2, 3 ]] >=20 > > tuple_ =3D ([ 1, 2, 3 ]) >=20 > > dict_ =3D [{ 1, 2, 3 }] >=20 > > frozendict_ =3D ({ 1, 2, 3 }) >=20 > > set_ =3D [< 1, 2, 3 >] >=20 > > frozenset_ =3D (< 1, 2, 3 >) >=20 >=20 >=20 > I am vehemently against using more than one "opening seq char" and one "c= losing seq char". It works fine for single depth sequences, however, once y= ou start nesting the mental focus required to parse the doubled openers/clo= sers is headache inducing. I would accept wrapping the literal in some sort= of declaration though, something like i proposed earlier in the thread. Th= e easiest is to use: >=20 >=20 >=20 > set({1,2,3}) >=20 >=20 >=20 > but that looks like a function call! So we'd need a unique syntax. Either= a single tag like: >=20 >=20 >=20 > set{1,2,3} >=20 >=20 >=20 > Or we could use start and end tags like: >=20 >=20 >=20 > set{1,2,3}set >=20 >=20 >=20 > where "set{" and "}set" are delimiters. For lists, tuples, and dict we wo= uld use the short form because these literals are far too ubiquitous: >=20 >=20 >=20 > [1,2,3] # list >=20 > {k:v} # dict >=20 > (1,2,3) # tuple >=20 >=20 >=20 > However, the grouping chars for tuples has always been confusing because = they can clash with grouping of expressions. What is this? >=20 >=20 >=20 > (1) >=20 >=20 >=20 > It's NOT a tuple! But it looks like a tuple! What is this: >=20 >=20 >=20 > 1,2 >=20 >=20 >=20 > it IS a tuple, but it does not look like a tuple!=20 >=20 >=20 >=20 > That's an unfortunate side effect of a poorly thought-out tuple syntax. I am thinking a mutated list temporarily is useful when a list is to be use= d=20 to be iterated through all of its elements efficiently. A permanently mutated list is a tuple of constant objects. As for the set type, I prefer to use the operations of the list, dictionaries in Python to act for the designed purposes.=20 =20