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

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
2 participants
@cclauss
Copy link
Contributor

commented Apr 17, 2019

Easier to read and understand plus avoids an is comparison with a string literal.

./contrib/inventory/cobbler.py:218:58: F632 use ==/!= to compare str, bytes, and int literals
                        if this_dns_name is not None and this_dns_name is not "":
                                                         ^

$ python

>>> raw = 'ra'
>>> raw += 'w'
>>> raw
'raw'
>>> raw == 'raw'
True
>>> raw is 'raw'
False
>>> 0 == 0.0
True
>>> 0 is 0.0
False
SUMMARY
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

contrib/inventory

ADDITIONAL INFORMATION

Avoid issue with use ==/!= to compare str, bytes, and int literals
Easier to read and understand plus avoids an ___is___ comparison with a string literal.
```
./contrib/inventory/cobbler.py:218:58: F632 use ==/!= to compare str, bytes, and int literals
                        if this_dns_name is not None and this_dns_name is not "":
                                                         ^
```

@ansibot ansibot added the stale_ci label Apr 25, 2019

@cclauss cclauss changed the title Avoid issue with use ==/!= to compare str, bytes, and int literals In Python, identity is not the same thing as equality Apr 27, 2019

@cclauss cclauss changed the title In Python, identity is not the same thing as equality Identity is not the same thing as equality in Python May 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.