Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38466
| 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!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.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; 'python,': 0.02; 'true,': 0.04; 'none,': 0.05; "'',": 0.07; '[],': 0.07; 'false,': 0.07; 'python': 0.09; 'bool': 0.09; 'spelled': 0.09; 'subject:while': 0.09; 'whichever': 0.09; '{},': 0.09; 'represents': 0.15; 'value.': 0.15; "'hello": 0.16; '0.0,': 0.16; 'boolean': 0.16; 'considering)': 0.16; 'flag,': 0.16; 'flags.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'non-empty': 0.16; 'values:': 0.16; 'wrote:': 0.17; "shouldn't": 0.17; "python's": 0.23; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'converting': 0.27; 'record': 0.28; '(possibly': 0.29; "d'aprano": 0.29; 'steven': 0.29; 'objects': 0.29; 'skip:_ 10': 0.29; 'e.g.': 0.30; 'function': 0.30; 'towards': 0.32; 'johnson': 0.32; 'to:addr:python-list': 0.33; 'false': 0.35; 'something': 0.35; 'method': 0.36; 'anything': 0.36; 'should': 0.36; 'why': 0.37; 'usual': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'most': 0.61; 'time,': 0.62; 'header:Reply-To:1': 0.68; 'wish': 0.70; 'reply-to:no real name:2**0': 0.72; 'special': 0.73; 'demonstrates': 0.84; 'flag.': 0.84; 'reply-to:addr:python.org': 0.84; 'canonical': 0.91; 'rick': 0.91 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.0 cv=XeZXOvF5 c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=Tv4_tr9OjFAA:10 a=u1UMZSm5KpQA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=aqH33drUsS4A:10 a=YAZmwk2O5BQBMCSrCcQA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 |
| X-AUTH | mrabarnett:2500 |
| Date | Fri, 08 Feb 2013 17:14:23 +0000 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Implicit conversion to boolean in if and while statements |
| 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> <f2b3fa89-d977-4ffd-8861-6a49fcbaf66c@g4g2000pbn.googlegroups.com> <67531902-cccc-4966-8278-b9948818dbde@googlegroups.com> <5114a7b5$0$30003$c3e8da3$5496439d@news.astraweb.com> |
| In-Reply-To | <5114a7b5$0$30003$c3e8da3$5496439d@news.astraweb.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | python-list@python.org |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1515.1360343660.2939.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1360343660 news.xs4all.nl 6841 [2001:888:2000:d::a6]:53943 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:38466 |
Show key headers only | View raw
On 2013-02-08 07:22, Steven D'Aprano wrote:
> Rick Johnson wrote:
>
>> Why even have a damn bool function if you're never going to use it?
>
> bool is for converting arbitrary objects into a canonical True or False
> flag. E.g. one use-case is if you wish to record in permanent storage a
> flag, and don't want arbitrary (possibly expensive) objects to be recorded.
>
> Most of the time, you shouldn't care whether you have a canonical True/False
> bool, you should only care whether you have something which duck-types as a
> boolean flag: a truthy or falsey value. In Python, all objects duck-type as
> flags. The usual interpretation is whether the object represents something
> or nothing:
>
> "nothing", or falsey values: None, False, 0, 0.0, '', [], {}, set(), etc.
> (essentially, the empty value for whichever type you are considering)
>
> "something", or truthy values: True, 1, 2.5, 'hello world', etc.
> (essentially, non-empty values).
>
Anything that's not falsey is truey.
> Prior to Python 3, the special method __bool__ was spelled __nonempty__,
> which demonstrates Python's philosophy towards duck-typing bools.
>
Incorrect, it was spelled __nonzero__.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-07 21:53 -0800
Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-08 17:15 +1100
Re: Implicit conversion to boolean in if and while statements Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-08 18:22 +1100
Re: Implicit conversion to boolean in if and while statements MRAB <python@mrabarnett.plus.com> - 2013-02-08 17:14 +0000
Re: Implicit conversion to boolean in if and while statements Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-09 09:18 +1100
Re: Implicit conversion to boolean in if and while statements Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-08 09:42 +0000
csiph-web