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 #4

Closed
wants to merge 2 commits into from

Conversation

cclauss
Copy link

@cclauss cclauss commented May 9, 2019

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

$ python

>>> dataset_mode = "CIFAR10"
>>> dataset_mode += '0'
>>> dataset_mode
'CIFAR100'
>>> dataset_mode == 'CIFAR100'
True
>>> dataset_mode is 'CIFAR100'
False
>>> 0 == 0.0
True
>>> 0 is 0.0
False

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

$ __python__
```python
>>> dataset_mode = "CIFAR10"
>>> dataset_mode += '0'
>>> dataset_mode
'CIFAR100'
>>> dataset_mode == 'CIFAR100'
True
>>> dataset_mode is 'CIFAR100'
False
>>> 0 == 0.0
True
>>> 0 is 0.0
False
```
@leaderj1001
Copy link
Owner

Thank you so much for your advice. But can you leave it as an issue? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants