<var> is None vs. <var> == None

Benjamin Kaplan benjamin.kaplan at case.edu
Fri Jan 23 19:24:38 EST 2009


On Fri, Jan 23, 2009 at 6:49 PM, Steven D'Aprano <
steve at remove-this-cybersource.com.au> wrote:

> On Fri, 23 Jan 2009 14:58:34 -0500, Gerald Britton wrote:
>
> > Hi -- Some time ago I ran across a comment recommending using <var> is
> > None instead of <var> == None (also <var> is not None, etc.)
>
> That entirely depends on whether you wish to test for something which
> *is* None or something with *equals* None. Those two things have
> different meanings.
>
> I wonder, do newbies actually get the impression from somewhere that "is"
> is a synonym for "=="?
>


I think it's more that teachers tell students without programming experience
"always use == to test if something equals something else unless you're
checking for None," without explaining what == and is actually mean.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090123/0329895a/attachment.html>


More information about the Python-list mailing list