Python Note: About comparison using is

It seems that the meaning is slightly different from "==". "is" is an exact match including the type.

print(1 == True)  # True
print(1 is True)  # False

Also, differences can be seen in the comparison between sequences.

li = [1,2,3]
st = [1,2,3]
print(li == st)  # True
print(li is st)  # False

By the way, I used to post a similar post in Javascript. http://qiita.com/juniskw/items/4a1f4d91fdf759e6a3da

Even if the two arrays have the same value, they seem to be different objects, so it seems that there is a difference. Does "==" simply compare values and "is" compares the objects themselves?

Or rather, I noticed it for the first time, but it seems that the meaning is slightly different between Python and Javascript even if it is the same "==".

Recommended Posts

Python Note: About comparison using is
About Python string comparison operators
A note about [python] __debug__
Python: A Note About Classes 1 "Abstract"
[Python] What is @? (About the decorator)
Note: Python
Python note
A note about mock (Python mock library)
python note: when easy_install is not available
About building GUI using TKinter of Python
Python memo using perl --format is convenient.
About February 02, 2020 * This is a Python article.
About python slices
About python comprehension
Python study note_002
Note: Python Decorator
Python programming note
[Python] Learning Note 1
Python is easy
First Python 3 ~ First comparison ~
About Python tqdm.
About python yield
About python, class
Python study note_004
Start using Python
About python inheritance
About python, range ()
Python study note_003
About python decorators
What is python
[Note] openCV + python
Note about awk
Python is instance
About python reference
About Python decorators
[Python] About multi-process
Python beginner's note
Scraping using Python
What is Python
About the difference between "==" and "is" in python
Get note information using Evernote SDK for Python 3
A note about the python version of python virtualenv
Data analysis in Python: A note about line_profiler
[Note] About the role of underscore "_" in Python
python int is infinite
About Python for loops
What I learned about AI / machine learning using Python (1)
Summary about Python scraping
About function arguments (python)
Python SDP runtime comparison
[Note] future sentence ~ Python ~
Operate Redmine using Python Redmine
[Note] File reading ~ Python ~
Fibonacci sequence using Python
[Python] What is Pipeline ...
Data analysis using Python 0
Note about pointers (Go)
Note that writing like this with ruby is writing like this with python
[Python] Memo about functions
Summary about Python3 + OpenCV3
[Question] About API conversion of chat bot using Python