Skip to content

Conversation

@cclauss
Copy link

@cclauss cclauss commented Mar 26, 2020

Identity is not the same thing as equality in Python so use ==/!= to compare str, bytes, and int literals. In Python >= 3.8, these instances will raise SyntaxWarnings so it is best to fix them now. https://docs.python.org/3.8/whatsnew/3.8.html#porting-to-python-3-8

% python3.8

>>> 'nt' is 'nt'
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> nt = 'n'
>>> nt += 't'
>>> nt == 'nt'
True
>>> nt is 'nt'
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
False

Identity is not the same thing as equality in Python so use ==/!= to compare str, bytes, and int literals. In Python >= 3.8, these instances will raise SyntaxWarnings so it is best to fix them now. https://docs.python.org/3.8/whatsnew/3.8.html#porting-to-python-3-8

% python3.8
```
>>> 'nt' is 'nt'
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> nt = 'n'
>>> nt += 't'
>>> nt == 'nt'
True
>>> nt is 'nt'
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
False
```
@cclauss cclauss closed this Jun 26, 2021
@cclauss cclauss deleted the patch-3 branch June 26, 2021 05:10
blambov pushed a commit to blambov/cassandra that referenced this pull request Sep 30, 2022
blambov pushed a commit to blambov/cassandra that referenced this pull request Nov 24, 2022
adelapena pushed a commit to adelapena/cassandra that referenced this pull request Sep 26, 2023
(cherry picked from commit 6aeb2ba)
(cherry picked from commit 62e1b50)
(cherry picked from commit 6fb43cc)
ekaterinadimitrova2 pushed a commit to ekaterinadimitrova2/cassandra that referenced this pull request Jun 3, 2024
(cherry picked from commit 6aeb2ba)
(cherry picked from commit 62e1b50)
(cherry picked from commit 6fb43cc)
(cherry picked from commit 220852d)
michaelsembwever pushed a commit to thelastpickle/cassandra that referenced this pull request Jan 7, 2026
(cherry picked from commit 6aeb2ba)
(cherry picked from commit 62e1b50)
(cherry picked from commit 6fb43cc)
(cherry picked from commit 220852d)
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.

1 participant