Both “is” and “==” are used for object comparison in Python. The operator “==” compares values of two objects, while “is” checks if two objects are same (In other words two references to same object).
The “==” operator does not tell us whether x1 and x2 are actually referring to the same object or not. We use “is” for this purpose.
No Yes Yes
- “is” returns True if two variables point to the same object.
- “==” returns True if two variables have same values(or content).
- Chaining comparison operators in Python
- Object Oriented Programming in Python | Set 2 (Data Hiding and Object Printing)
- Python | Data Comparison and Selection in Pandas
- Object Oriented Programming in Python | Set 1 (Class, Object and Members)
- Python | Tkinter ttk.Checkbutton and comparison with simple Checkbutton
- Python | object() method
- Python | Check if a given object is list or not
- pickle — Python object serialization
- marshal — Internal Python object serialization
- Python | Convert dictionary object into string
- Python | Matplotlib Sub plotting using object oriented API
- Python __iter__() and __next__() | Converting an object into an iterator
- Python | Ways to convert string to json object
- Data type Object (dtype) in NumPy Python
- OOP in Python | Set 3 (Inheritance, examples of object, issubclass and super)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.