Skip to content

Files

Latest commit

 

History

History
25 lines (16 loc) · 489 Bytes

File metadata and controls

25 lines (16 loc) · 489 Bytes

Pattern: Missing use of is not for object identity test

Issue: -

Description

Tests for object identity should use the form x is not None rather than not x is None. The former example is more readable.

Example of incorrect code:

if not user is None:
    print(user.name)

Example of correct code:

if user is not None:
    print(user.name)

Further Reading