'is' vs '==' in python
# '==' : value equality-two objects have the same value # is : reference equality- two references refer to the same object a=[ 1 , 2 , 3 ] b=a #two references refer to the same object(b is not the copy of a) print (b==a) print (b is a) c=a[:] #two references refer to the two different object(now c is the copy of a) print (c==a) print (c is a)


Comments
Post a Comment