===============================================================
7. Identity Operators
===============================================================
=>The purpose of Identity Operators is that "To Compare the Memory Address of Two
Objects".
=>In Python Programming, we have Two Types of Identity Operators. They are
1. is Operator
2. is not Operator
-----------------------------------------------------------------------------------
------------------------------------------------------------------------
1. is Operator
-----------------------------------------------------------------------------------
------------------------------------------------------------------------
Syntax: Object1 is Object2
=>The 'is' Operator returns True Provided the Memory Address of Object1 and Object2
are Same.
=>The 'is' Operator returns False Provided the Memory Address of Object1 and
Object2 are Different.
-----------------------------------------------------------------------------------
------------------------------------------------------------------------
2. is not Operator
-----------------------------------------------------------------------------------
------------------------------------------------------------------------
Syntax: Object1 is not Object2
=>The 'is not ' Operator returns True Provided the Memory Address of Object1 and
Object2 are Different.
=>The 'is not ' Operator returns False Provided the Memory Address of Object1 and
Object2 are Same.
-----------------------------------------------------------------------------------
------------------------------------------------------------------------
Most Imp
-----------------------------------------------------------------------------------
------------------------------------------------------------------------
NOTE: What are all the Objects are in DEEP COPY then Those Objects Contains Same
Address and 'is' Operator on those
Objects returns True and 'is not' returns False
NOTE: What are all the Objects are in SHALLOW COPY then Those Objects Contains
Different Address and 'is not'
Operator on those Objects returns True and 'is' returns False.
------------------------
Examples
------------------------
>>> lst1=[10,"RS",23.45]
>>> print(lst1,id(lst1))-----------------[10, 'RS', 23.45] 1479399606592
>>> lst2=lst1 # Deep Copy
>>> print(lst2,id(lst2))-----------------[10, 'RS', 23.45] 1479399606592
>>> lst1 is lst2---------------------------True
>>> lst1 is not lst2----------------------False
------------------------------------
>>> lst1=[10,"RS",23.45]
>>> print(lst1,id(lst1))---------------[10, 'RS', 23.45] 1479399618304
>>> lst2=lst1.copy()
>>> print(lst2,id(lst2))---------------[10, 'RS', 23.45] 1479399620480
>>> lst1 is lst2-------------------------False
>>> lst1 is not lst2--------------------True
-----------------------------------------------------------------------------------
------------------------------------------------------------------------