Chris Angelico <ros...@gmail.com> wrote: > On Sun, Jan 17, 2016 at 8:51 PM, Ulli Horlacher > <frams...@rus.uni-stuttgart.de> wrote: > > I have seen at several places "x == None" and "x is None" within > > if-statements. > > What is the difference? > > Which term should I prefer and why? > > tl;dr: Prefer "x is None" as a check.
And for the negation? "if not x is None" or "if x is not None" I have seen the last one several times, but i do not understand it, because: >>> x=0 >>> x is not None True >>> not None True >>> x is True False -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de Universitaet Stuttgart Tel: ++49-711-68565868 Allmandring 30a Fax: ++49-711-682357 70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ -- https://mail.python.org/mailman/listinfo/python-list