Python‎ > ‎operator‎ > ‎

operator.is_()

http://www.adilwaseem.com/

Introduction
The method return with test whether a is b.

Syntax
operator.is_(a,b)

Parameters
a,b=string & number

Examples
The operator test the equality of the number.
 >>> operator.is_(3,2)
False
>>> 
>>> operator.is_(3,3)
True
>>> 

operator.is_(str,str)
The operator tested the string values.
 >>> operator.is_("Python", "Lake")
False
>>> operator.is_("Python", "Python")
True

a(str) is b(str)
The results are string return positive.
 >>> "Python" is "Python"
True
>>> 

operator.is_(list1,list2)
The operator tested whether x  list is y list.
 >>> 
>>> x=["Python", "Research", "Centre"]
>>> y=["Python", "Centre", "Research"]
>>> operator.is_(x,y)
False

Further evaluation of method on list and its results.
 
>>> x=["Python", "Research", "Centre"]
>>> y=["Python", "Centre", "Research"]
>>> x.sort()
>>> y.sort()
>>> operator.is_(x,y)
False
>>> x
['Centre', 'Python', 'Research']
>>> y
['Centre', 'Python', 'Research']
>>> operator.is_(x,y)
False

a(list) is b(list)
The list returns with:
 >>> ['Centre', 'Python', 'Research'] is ['Centre', 'Python', 'Research']
False

operator.is_(tuple1, tuple2)
The return is tuple is:
 >>> x=('Centre', 'Python', 'Research')
>>> y=('Centre', 'Python', 'Research')
>>> operator.is_(x,y)
False
>>> x is y
False



Comments