Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101868
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: "x == None" vs "x is None" |
| Date | 2016-01-18 13:46 +1100 |
| Message-ID | <mailman.83.1453085214.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> |
<paul.hermeneutic@gmail.com> writes: > I prefer (x is None) and (x is not None). There are good reasons to prefer this. But this is not a good reason: > This matches the SQL concept of NULL. That's not really helpful, because it *doesn't* match. > (X = NULL) is not valid since NULL is not a value and cannot be > compared with anything. SQL Null fails comparison with any value. Python ``None`` is a value and can be compared like any other value. SQL Null is neither truthy nor falsy; three-value logic is required when Null can occur. Python ``None`` is falsy by definition, and two-value (Boolean) logic continues to obtain. SQL Null is not a value and has no data type. Python ``None`` is an object and, like any other object, has a type defining the operations that it can perform. And so on. While some libraries do conflate SQL Null with Python ``None``, the two concepts really behave quite differently. It is needlessly misleading to say they “match” in any sense. I'm in the camp that says, while SQL is quite useful, its NULL is a wart <URL:https://dba.stackexchange.com/questions/5222/why-shouldnt-we-allow-nulls/6049>. -- \ “… it's best to confuse only one issue at a time.” —Brian W. | `\ Kernighan and Dennis M. Ritchie, _The C programming language_, | _o__) 1988 | Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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