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


Groups > comp.lang.python > #101861

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

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: "x == None" vs "x is None"
Date 2016-01-18 08:38 +1100
Message-ID <mailman.76.1453066742.15297.python-list@python.org> (permalink)
References (1 earlier) <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>

Show all headers | 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