Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cclauss
Copy link
Contributor

@cclauss cclauss commented May 10, 2019

Summary

Identity is not the same thing as equality in Python. We want the latter in these instances.

Details and comments

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

$ python

>>> id = "i"
>>> id += 'd'
>>> id
'id'
>>> id == 'id'
True
>>> id is 'id'
False
>>> 0 == 0.0
True
>>> 0 is 0.0
False

@atilag
Copy link
Member

atilag commented May 13, 2019

You are totally right @cclauss
Thanks for the contribution!

@atilag
Copy link
Member

atilag commented May 13, 2019

Tests are failiing due to Terra upgrade, everything seems correct in you side though.

@atilag atilag merged commit 5baee79 into Qiskit:master May 13, 2019
@cclauss cclauss deleted the equality branch May 13, 2019 13:09
dcmckayibm pushed a commit to dcmckayibm/qiskit-aer that referenced this pull request Nov 3, 2019
Identity is not the same thing as equality in Python
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.

2 participants