Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #69373
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:not': 0.03; 'operator': 0.03; 'odd': 0.07; 'subject:two': 0.07; 'variables': 0.07; 'subject:None': 0.09; 'subtle': 0.09; 'way:': 0.09; 'cc:addr :python-list': 0.11; 'bug': 0.12; 'assume': 0.14; 'wrote': 0.14; '"is': 0.16; 'background,': 0.16; 'chained': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mean,': 0.16; 'sense:': 0.16; 'two,': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'bit': 0.19; 'written': 0.21; 'seems': 0.21; '(the': 0.22; 'cc:addr:python.org': 0.22; 'mathematical': 0.24; 'cc:2**0': 0.24; 'order.': 0.26; 'this:': 0.26; 'second': 0.26; 'asking': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'points': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'agreed.': 0.31; 'are.': 0.31; 'constant': 0.31; "d'aprano": 0.31; 'operators': 0.31; 'steven': 0.31; 'way?': 0.31; 'quite': 0.32; 'open': 0.33; 'checking': 0.33; 'sense': 0.34; 'maybe': 0.34; 'problem': 0.35; "can't": 0.35; 'good.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'i.e.': 0.36; 'useful': 0.36; 'two': 0.37; 'clear': 0.37; 'checks': 0.38; 'e.g.': 0.38; 'fact': 0.38; 'pm,': 0.38; 'rather': 0.38; 'does': 0.39; 'skip:u 10': 0.60; 'strictly': 0.61; "you're": 0.61; 'first': 0.61; 'high': 0.63; 'more': 0.64; 'different': 0.65; '30,': 0.65; 'within': 0.65; 'between': 0.67; 'mar': 0.68; 'line,': 0.68; 'saw': 0.77; 'low': 0.83; 'bounded': 0.84; "it'd": 0.84; 'maths': 0.84; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=qJPeGrMxtfv336JuY3rKLQxEfsmtTZ1AZHByKUVb69s=; b=hMNE6itipBrREkqItRmlXU0UbtD7KZ2gDHQMNF2V8PWQPyP/0iRmT5sd+usLoF58OP Q2K3pJPwAcIjCbVYRLaor6s85MzTey8ZqWXsTBYGlQ8uzubKAytwO05mwn6KAyCEdt+u VzJME8umPVrxQNC09Zi8sJywE5VD/v+T8TDBPsTOp1ZxBKH0/otCzuCoN2C2cpltHCwB nK8mn5+To06audcpwcJcc6pkKK6nudDdW1QnSkw/Ng34jDMmJ36+wV7aKfFQIXkrc6cZ gGJE2zdhSXcaOb9V9M2zfE3cofYvhE7zfvqME0AJ/9bJTqEI/OP2hqVnp530jEdk7o98 D/kA== |
| MIME-Version | 1.0 |
| X-Received | by 10.66.150.69 with SMTP id ug5mr17815877pab.55.1396160254569; Sat, 29 Mar 2014 23:17:34 -0700 (PDT) |
| In-Reply-To | <5337b182$0$29994$c3e8da3$5496439d@news.astraweb.com> |
| References | <0245aca0-c6b7-493a-aa52-2c3ef6462dbd@googlegroups.com> <5337195f$0$29994$c3e8da3$5496439d@news.astraweb.com> <lh7cb4$ntu$2@news.albasani.net> <roy-B5E8CC.17072029032014@news.panix.com> <53377b9e$0$29994$c3e8da3$5496439d@news.astraweb.com> <mailman.8709.1396145720.18130.python-list@python.org> <5337b182$0$29994$c3e8da3$5496439d@news.astraweb.com> |
| Date | Sun, 30 Mar 2014 17:17:34 +1100 |
| Subject | Re: checking if two things do not equal None |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8712.1396160262.18130.python-list@python.org> (permalink) |
| Lines | 63 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1396160262 news.xs4all.nl 2902 [2001:888:2000:d::a6]:55719 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:69373 |
Show key headers only | View raw
On Sun, Mar 30, 2014 at 4:54 PM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Sun, 30 Mar 2014 13:15:18 +1100, Chris Angelico wrote: > >> Chained comparisons where you're checking a single variable against two >> constants make perfect sense: >> >> 2 < x < 5 >> >> Chained comparisons where you check a single constant against two >> variables don't, so much: >> >> x < 2 < y >> >> What exactly does that mean, and why is it written that way? > > It checks that 2 is strictly bounded between x on the left and y on the > right, i.e. that 2 is inside the open interval x...y. I don't know why > you think that's unclear. But then I do have a maths background and I'm > used to chaining comparisons. > > Write it like this: > > low = x > high = y > a = 2 > > low < a < high > > Does that make more sense? Well-chosen names are good. The fact that a is > a constant rather than a variable is no big deal: > > low < 2 < high The problem isn't that I can't see what the comparisons are. It makes very good sense to bound a variable within constants; but you already know exactly where 2 is on the number line, so asking "Is 2 between these two variables" seems a bit odd. Maybe it's less so with the strong mathematical background, but it seems odd to me. >> It'd be more useful but less clear if one of the conditions points the >> other way: >> >> x < 2 > y >> >> which checks that they're both less than two, > > which is quite different from what you wrote the first time. > > >> but IMO in a less-than-clear way. > > That's an understatement. If I saw code chaining comparisons in that > fashion, I would assume the second operator > was a typo. > > Chaining less-than and greater than operators should, for clarity, always > be written in a single order. E.g. a <= b < c < d, not a <= b < d > c. > > (The second contains a subtle bug too.) Agreed. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
checking if two things do not equal None contact.trigon@gmail.com - 2014-03-29 11:56 -0700
Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-29 19:05 +0000
Re: checking if two things do not equal None contact.trigon@gmail.com - 2014-03-29 12:23 -0700
Re: checking if two things do not equal None Lele Gaifax <lele@metapensiero.it> - 2014-03-29 20:24 +0100
Re: checking if two things do not equal None Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-03-29 22:01 +0100
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 17:07 -0400
Re: checking if two things do not equal None Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-03-29 22:55 +0100
Re: checking if two things do not equal None Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-03-29 23:02 +0100
Re: checking if two things do not equal None Dave Angel <davea@davea.name> - 2014-03-29 18:01 -0400
Re: checking if two things do not equal None contact.trigon@gmail.com - 2014-03-29 16:20 -0700
Re: checking if two things do not equal None Tim Chase <python.list@tim.thechases.com> - 2014-03-29 17:36 -0500
Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 02:24 +0000
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 22:43 -0400
Re: checking if two things do not equal None Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-03-29 22:04 -0500
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 18:41 -0400
Re: checking if two things do not equal None Tim Chase <tim@thechases.com> - 2014-03-29 17:46 -0500
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 18:51 -0400
Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 10:17 +1100
Re: checking if two things do not equal None Tim Chase <python.list@tim.thechases.com> - 2014-03-29 20:19 -0500
Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 12:37 +1100
Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 02:04 +0000
Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 13:15 +1100
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 22:39 -0400
Re: checking if two things do not equal None Rustom Mody <rustompmody@gmail.com> - 2014-03-29 19:54 -0700
Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 06:08 +0000
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-30 08:21 -0400
Re: checking if two things do not equal None MRAB <python@mrabarnett.plus.com> - 2014-03-30 14:58 +0100
Re: checking if two things do not equal None Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-31 11:48 +1300
Re: checking if two things do not equal None Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-30 19:41 +1300
Re: checking if two things do not equal None Marko Rauhamaa <marko@pacujo.net> - 2014-03-30 10:37 +0300
Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 05:54 +0000
Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 17:17 +1100
Re: checking if two things do not equal None Ben Finney <ben+python@benfinney.id.au> - 2014-03-30 17:52 +1100
Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 18:36 +1100
Re: checking if two things do not equal None Ethan Furman <ethan@stoneleaf.us> - 2014-03-29 16:20 -0700
Re: checking if two things do not equal None Terry Reedy <tjreedy@udel.edu> - 2014-03-29 19:02 -0400
Re: checking if two things do not equal None Jeremy Sanders <jeremy@jeremysanders.net> - 2014-03-31 09:56 +0200
Re: checking if two things do not equal None Abe <contact.trigon@gmail.com> - 2014-03-31 10:28 -0700
Re: checking if two things do not equal None Moritz Emanuel Beber <moritz.beber@gmail.com> - 2014-03-31 21:22 +0200
csiph-web