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


Groups > comp.lang.python > #101861

Re: "x == None" vs "x is None"

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: "x == None" vs "x is None"
Date Mon, 18 Jan 2016 08:38:59 +1100
Lines 26
Message-ID <mailman.76.1453066742.15297.python-list@python.org> (permalink)
References <n7fo7q$dso$1@news2.informatik.uni-stuttgart.de> <mailman.57.1453025729.15297.python-list@python.org> <n7fshb$f36$1@news2.informatik.uni-stuttgart.de> <CAPTjJmrDZCiDLmRtiukDv2Z1Gz69fz3+_4xYeu-PoXBdC3dtGg@mail.gmail.com> <CAJ4+4aoHHzFJNHvw+LjimO6qHr6dsUskMsQw6y+uiW0jrQzm-w@mail.gmail.com> <m237tvj3hi.fsf@fastmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de k03iO4Qtyd7AqE8Z4/S8PAs+ddpfgM7gk1LINfkLCJoA==
Return-Path <rosuav@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; 'operator': 0.03; 'received:209.85.223': 0.03; 'none,': 0.05; 'expressions': 0.07; 'matches': 0.07; 'none)': 0.07; 'cc:addr:python-list': 0.09; 'behave': 0.09; 'differently.': 0.09; 'subject:None': 0.09; 'jan': 0.11; '"is': 0.16; '2016': 0.16; 'distinct': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'none).': 0.16; 'null.': 0.16; 'partly': 0.16; 'pointer,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'somewhere.': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'not,': 0.22; 'null)': 0.22; 'trying': 0.22; 'am,': 0.23; "python's": 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'compare': 0.27; 'message-id:@mail.gmail.com': 0.27; 'operators': 0.29; 'compared': 0.30; 'another': 0.32; 'null': 0.33; 'received:google.com': 0.35; 'generic': 0.35; 'quite': 0.35; "isn't": 0.35; 'but': 0.36; 'received:209.85': 0.36; 'subject:" ': 0.36; 'really': 0.37; 'two': 0.37; 'received:209': 0.38; 'represent': 0.38; 'some': 0.40; 'is.': 0.63; 'different': 0.63; 'other.': 0.64; 'worth': 0.67; 'chrisa': 0.84; 'from"': 0.84; 'to:none': 0.91
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=vVf56/OVQNOrbF93irLzAyfBh2M8S+dz+s7ItH5M5+k=; b=aszyvdYyJm1mI50pstTjHSiqgrIrlu+vNA0WkIEmjH3CU5eIIDvnK/tqVp2G4H64eT GPvFs7juHd1EpIy5L01wDVLnZ2uolwR9qh/IRAqV4Po9IExpLV4+LYg8V3rr+12n1wTd 4yquON79rXggQjBx7MKOCOtbF2v3mfOSzHsLC5nXHH4r1JJzlbq6Ewnf1oIxWf+JZvTT aMRK0FdiiFKJfVTuxtFBk9SVo0UJdVusvEXaUTOilq0350Lt69w+xTx0OSxvCG2l5zdG 5DdGEgwoWr7/QjOX7NTW5q0vb2wMABrm4WJZlTyxxs2aXbyAdgDFTuPz7a7IKAzyi7Qf XZkQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type; bh=vVf56/OVQNOrbF93irLzAyfBh2M8S+dz+s7ItH5M5+k=; b=ETFkRpxcKTFZ2Ch43kO16PR4z9aIREY4u7JucLLfHd7ckUcqwBUI22e/2rXRIx3NIN o35n4Xnj9dBNh1MCFjjVNcFWjxDrArwjKoSLByUC/Y8p0qxPe5mWRxxMfzCeeTZKSKgi XXAXP9TO9xuOs2+2877pSNLJT+fZHjEkjtNsZ3EPwWI7HoNOls0fK1miKbl4QaxI8bvo /RUA2pj36JCGZEVzELJxK6o9fXbX6CfOLDjpGRjN/lzFZhfxr+rdjmyxxIdc8d3akj/y s5qkxp6uM5Lv5YqjrL9zcko+Ag6e2pu5/CFOa95KdC05umJszffCRpt1Wo37KBXDql1u XdkQ==
X-Gm-Message-State ALoCoQm+oLVCRp9nmO9ovEWHita0exG87zxJ6DWQjdzR9xZHZIh9gUm0MMgx20gaKaB78DX8cZnHw9F2UgzgJaynBbyYR06v2w==
X-Received by 10.107.40.76 with SMTP id o73mr17440952ioo.157.1453066739394; Sun, 17 Jan 2016 13:38:59 -0800 (PST)
In-Reply-To <m237tvj3hi.fsf@fastmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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>
Xref csiph.com comp.lang.python:101861

Show key headers only | View raw


On Mon, Jan 18, 2016 at 8:33 AM, Random832 <random832@fastmail.com> wrote:
> <paul.hermeneutic@gmail.com> writes:
>
>> I prefer (x is None) and (x is not None).
>>
>> This matches the SQL concept of NULL.
>>
>> (X = NULL) is not valid since NULL is not a value and cannot be compared
>> with anything.
>
> The suitably generic SQL operator is "is (not) distinct from", in some
> dialects of SQL [certainly if you're using NULL directly you can simply
> use is/is not, but the "distinct from" operators can be used to compare
> two expressions that may either or both be NULL.
>
> "X is not distinct from Y" == "X = Y or X is NULL and Y is NULL"

It's worth noting that Python's None is not really the same as SQL's
NULL... although that's partly because nothing is. NULL isn't quite
the same as IEEE NaN, nor C's null pointer, nor Python's None, all of
which are quite different from each other. All of them can be used to
represent some of the same concepts, but they behave very differently.
Trying to explain one in terms of another is likely to trip people up
somewhere.

ChrisA

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


Thread

"x == None" vs "x is None" Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-01-17 09:51 +0000
  Re: "x == None" vs "x is None" Chris Angelico <rosuav@gmail.com> - 2016-01-17 21:15 +1100
    Re: "x == None" vs "x is None" Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-01-17 11:05 +0000
      Re: "x == None" vs "x is None" Peter Otten <__peter__@web.de> - 2016-01-17 12:26 +0100
      Re: "x == None" vs "x is None" Chris Angelico <rosuav@gmail.com> - 2016-01-17 22:29 +1100
      Re: "x == None" vs "x is None" <paul.hermeneutic@gmail.com> - 2016-01-17 11:01 -0700
      Re: "x == None" vs "x is None" Random832 <random832@fastmail.com> - 2016-01-17 16:33 -0500
      Re: "x == None" vs "x is None" Chris Angelico <rosuav@gmail.com> - 2016-01-18 08:38 +1100
      Re: "x == None" vs "x is None" Ben Finney <ben+python@benfinney.id.au> - 2016-01-18 13:46 +1100
  Re: "x == None" vs "x is None" fernando junior <fernandojr.ifcg@live.com> - 2016-01-19 14:20 -0800

csiph-web