Permanent objects?

Dave Brueck dave at pythonapocrypha.com
Thu Dec 26 22:29:58 EST 2002


On Wed, 25 Dec 2002, Kevin Altis wrote:

> Hmm, I think I tend to use
>
>   if x == None:
> and
>   if x != None:
>
> rather than
>
>   if x is None:
> and
>   if not x is None:
>
> I don't suppose it really matters or that one is better or clearer than the
> other?

Somebody else in this thread gave a nice explanation of why 'is' makes
sense when None is used as a sentinel, so I'll just add that the following
is valid Python too:

if x is not None:
 dosomething

(ie you don't have to use "if not (x is None)" or something).

-Dave




More information about the Python-list mailing list