- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
Python Object Comparison â€śisâ€ť vs â€ś==â€ť
In this article, we will learn about object comparision i.e. between < is > operator & equality operator < == > .
The equality operator works on the value of the passed argument whereas is operator compares the reference of the two objects passed as arguments.
In case of equality operator contents of the argument are compared ignoring their references that means the same content stored at different locations is considered identical, whereas while using is operator references are the top priority.
Now let’s observe the concept in the implementation below −
list_1 = ['t','u','t','o','r'] list_2 = ['t','u','t','o','r'] list_3=list_1 if (list_1 == list_2): print("True") else: print("False") if (list_1 is list_2): print("True") else: print("False") if (list_1 is list_3): print("True") else: print("False")
True False True
All the variables are declared in the local scope and their references are seen in the figure above.
In this article, we have learned about python object comparison by using equality & the referencing operator(is).
- Related Articles
- Sales Vs Marketing: A Detailed Comparison
- Linux Commands Comparison curl vs wget
- Blockchain Ledger Vs Ordinary Ledger: A Detailed Comparison
- Python Comparison Operators
- Comparison of autoboxed integer object in Java\n
- Comparison between AC and DC Traction System (AC Traction vs DC Traction)
- Chaining comparison operators in Python
- C++ vs Java vs Python?
- Comparison between E-R Model and Object Oriented Model
- Cplus plus vs Java vs Python?
- How to overload Python comparison operators?
- List vs tuple vs dictionary in Python
- String Literal Vs String Object in C#