# В чем разница в использовании между is и ==?

### 1. **`==`** — сравнение значений (equality)

* Проверяет, **равны ли значения** объектов.
* Вызывает метод `__eq__` объекта.
* Даже если объекты разные в памяти, но содержат одинаковые данные — `==` вернёт `True`.

```python
a = [1, 2, 3]
b = [1, 2, 3]

print(a == b)  # True  (списки с одинаковым содержимым)
```

***

### 2. **`is`** — сравнение идентичности (identity)

* Проверяет, **являются ли два имени ссылками на один и тот же объект в памяти**.
* Сравнивает `id(a)` и `id(b)`.

```python
a = [1, 2, 3]
b = a

print(a is b)   # True  (ссылаются на один объект)
print(a == b)   # True  (и значения одинаковы)
```

***

### 3. Пример, когда `==` и `is` различаются

```python
x = [1, 2, 3]
y = [1, 2, 3]

print(x == y)  # True  (одинаковые данные)
print(x is y)  # False (разные объекты в памяти)
```

***

💡 В автотестах часто встречается:

```python
# Хорошо
if result is None:
    ...

# Плохо (работает, но менее читаемо)
if result == None:  # noqa: E711
    ...
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kaze.gitbook.io/qa-theory/osnovy-programmirovaniya-na-python/v-chem-raznica-v-ispolzovanii-mezhdu-is-i.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
