Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38417

Re: Implicit conversion to boolean in if and while statements

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rantingrickjohnson@gmail.com>
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; '16,': 0.03; 'argument': 0.04; 'explicitly': 0.04; 'method.': 0.05; 'type,': 0.07; 'python': 0.09; '"if': 0.09; 'bool': 0.09; 'collections': 0.09; 'inherited': 0.09; 'input,': 0.09; 'len,': 0.09; 'object;': 0.09; 'oop,': 0.09; 'setattr,': 0.09; 'str,': 0.09; 'subject:while': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'stack': 0.15; 'beginning.': 0.16; 'container.': 0.16; 'eliminating': 0.16; 'etc...': 0.16; 'idea!': 0.16; 'reason.': 0.16; 'suggesting': 0.16; 'tuple,': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'any,': 0.17; 'all,': 0.21; 'implicit': 0.22; 'int,': 0.22; 'tells': 0.22; 'cc:2**0': 0.23; 'monday,': 0.23; 'cc:no real name:2**0': 0.24; 'idea': 0.24; 'second': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'am,': 0.27; 'container': 0.29; "d'aprano": 0.29; 'oop': 0.29; 'steven': 0.29; 'classes': 0.30; 'help,': 0.32; 'could': 0.32; 'him.': 0.33; 'interface,': 0.33; 'received:google.com': 0.34; 'nature': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'method': 0.36; 'should': 0.36; 'too': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'instead': 0.39; 'list,': 0.39; 'think': 0.40; 'your': 0.60; 'july': 0.60; 'side': 0.61; 'more': 0.63; 'great': 0.64; 'become': 0.65; 'incorporate': 0.65; 'jul': 0.65; 'subject.': 0.65; 'reply': 0.66; 'talking': 0.66; 'believe': 0.69; 'bag': 0.75; '100%': 0.76; 'flip': 0.84; 'float,': 0.84
X-Received by 10.49.1.43 with SMTP id 11mr368599qej.29.1360304172929; Thu, 07 Feb 2013 22:16:12 -0800 (PST)
Newsgroups comp.lang.python
Date Thu, 7 Feb 2013 22:16:12 -0800 (PST)
In-Reply-To <mailman.2197.1342498752.4697.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=70.196.110.35; posting-account=h3aEwQoAAACiuqX-oR3gvCVFm8lLHoWj
References <mailman.2132.1342341291.4697.python-list@python.org> <5002a1f9$0$29995$c3e8da3$5496439d@news.astraweb.com> <mailman.2141.1342369188.4697.python-list@python.org> <7b027612-a07e-40f9-8ad2-3e95c5440482@googlegroups.com> <mailman.2148.1342375350.4697.python-list@python.org> <bbc44546-ffb7-4ff9-bd43-3bfa068df75f@googlegroups.com> <mailman.2154.1342389192.4697.python-list@python.org> <86872ad2-fda0-403b-9f18-d1cb18e41860@t32g2000yqd.googlegroups.com> <CAPTjJmov--b_s5e=OYsWWV8w6byj5a+28NNu-vRWGV8mr8w5cg@mail.gmail.com> <mailman.2159.1342404957.4697.python-list@python.org> <50039290$0$29978$c3e8da3$5496439d@news.astraweb.com> <mailman.2197.1342498752.4697.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 70.196.110.35
MIME-Version 1.0
Subject Re: Implicit conversion to boolean in if and while statements
From Rick Johnson <rantingrickjohnson@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.1482.1360304697.2939.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1360304697 news.xs4all.nl 6889 [2001:888:2000:d::a6]:36462
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:38417

Show key headers only | View raw


On Monday, July 16, 2012 11:18:28 PM UTC-5, Devin Jeanpierre wrote:
> On Mon, Jul 16, 2012 at 12:03 AM, Steven D'Aprano wrote:
> > On Sun, 15 Jul 2012 22:15:13 -0400, Devin Jeanpierre wrote:
> >
> >> For example, instead of "if stack:" or "if bool(stack):", we could use
> >> "if stack.isempty():". This line tells us explicitly that stack is a
> >> container.
> >
> > isempty is not a container method.
> 
> Your entire reply is predicated on this idea that I was talking about
> writing classes with this extra "isempty" method.

Steven's adherence to this implicit conversion is warping his comprehension of your words. He is so accustomed to "guessing" that it has become second nature for him.

> No. I was talking about having "isempty" be part of the collection
> interface, and eliminating polymorphic bool conversion.

Which i believe is a great idea! 

GvR has always been reluctant to incorporate full OOP machinery for some reason. I am not suggesting that Python be 100% OOP, HELL NO! But collections should have had an "isempty" method from the beginning. But the same argument could be made against len, any, all, etc...

But now we are opening a whole bag of cats. What about hasattr, getattr, setattr, type, dir, id, isinstance, issubclass, and many more that could be inherited directly from object; and they should be!

On the flip side i do believe int, float, str, tuple, list, dict... should remain as built-ins, and the obvious: help, input, globals, locals, vars, print, etc... 

Python has too many built-ins. I think we need a PyWart on this subject.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-07 22:16 -0800

csiph-web