# Python None: How to Use the Null Object Correctly

> Use None as the null equivalent in Python, test for it with the is operator instead of ==, and understand its falsy behavior in boolean expressions

**URL:** https://sentry.io/answers/use-the-null-object-in-python/

---

## The Problem

How can I use null values in Python?

## The Solution

[`None`](https://docs.python.org/3/library/constants.html#None) is Python's equivalent of null. It is a singleton object of the class [`NoneType`](https://docs.python.org/3/library/types.html#types.NoneType). It is universally available and cannot be reassigned. To test whether a variable is `None`, we should use Python's `is` identity operator, as below:

```python
my_object = None
if my_object is None:
    print("It's null!")
```

Using `is` is preferable to using `==`, as the latter can be overloaded, which may lead to unexpected behavior when used with certain objects.

`None` is *falsy*, which means that it will be considered equivalent to `False` when used in boolean expressions.

```python
if None:
    print("This line will never execute")
else:
    print("This line will always execute")
```

---

*Source: [sentry.io/answers/use-the-null-object-in-python/](https://sentry.io/answers/use-the-null-object-in-python/)*
