Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identity is not the same thing as equality in Python #5713

Merged
merged 1 commit into from May 22, 2019

Conversation

@cclauss
Copy link
Contributor

@cclauss cclauss commented May 22, 2019

Identity is not the same thing as equality in Python. In this instance, we want the latter.

Use ==/!= to compare str, bytes, and int literals.

$ python

>>> result = 'choic'
>>> result += 'e'
>>> result == 'choice'
True
>>> result is 'choice'
False
Identity is not the same thing as equality in Python.  In this instance, we want the latter.

Use ==/!= to compare str, bytes, and int literals.

$ __python__
```python
>>> result = 'choic'
>>> result += 'e'
>>> result == 'choice'
True
>>> result is 'choice'
False
```
Copy link
Member

@humitos humitos left a comment

Makes sense.

Thanks.

@humitos humitos merged commit 8726fb6 into readthedocs:master May 22, 2019
1 check passed
@cclauss cclauss deleted the patch-1 branch May 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants