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).
- Python | Excel File Comparison
- Python | Consecutive String Comparison
- Chaining comparison operators in Python
- Object Oriented Programming in Python | Set 2 (Data Hiding and Object Printing)
- Object Oriented Programming in Python | Set 1 (Class, Object and Members)
- Python | Data Comparison and Selection in Pandas
- Python | Find Hotel Prices using Hotel price comparison API
- Python | Tkinter ttk.Checkbutton and comparison with simple Checkbutton
- Python object
- Python | os.supports_follow_symlinks object
- Python | os.supports_fd object
- Python | os.supports_bytes_environ object
- Python | object() method
- Python | os.sysconf_names object
- Python | os.confstr_names object
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.