Skip to content

None Compare

Documentation Index

Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt

Use this file to discover all available pages before exploring further.

Replaces == with is when comparing to None

if hat == None:
raise NoHatException
if hat is None:
raise NoHatException

In Python is refers to reference equality - where you want to check if something is the same object. Equals == checks value equality, to check that the objects are equal to each other. In Python the None object is a singleton, so it is correct to use is when comparing to it.