Files
freeCodeCamp/guide/portuguese/python/difference-between-is-and-equal-equal-operators/index.md
2018-10-16 21:32:40 +05:30

27 lines
785 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Difference between Python 'is' and '==' operators
localeTitle: Diferença entre os operadores Python 'is' e '=='
---
`is` é uma verificação da identidade do objeto - isto é, verificar se duas ou mais variáveis estão se referindo ao mesmo objeto. Você não pode sobrecarregar `is` .
`==` avalia como verdadeiro se o objeto referido pelas variáveis for igual. Você pode sobrecarregar `==` através do operador `__eq__` .
## Valor de retorno
O valor de retorno para ambos seria `True` ou `False` .
## Amostra de código
```
a = 2.3
a is 2.3 # => False
a == 2.3 # => True
a = [234,123,321]
b = [234,123,321]
a == b # => True
a is b # => False
a = b
a == b # => True
a is b # => True, because if we change a, b changes too
```