Pragmatics of the standard is() function
candide
candide at free.invalid
Sat Nov 26 16:20:36 EST 2011
In which cases should we use the is() function ? The is() function
compares identity of objects rather than values so I was wondering in
which circumstances comparing identities of objects is really vital.
Examining well reputated Python source code, I realize that is()
function is mainly used in the following set form :
spam is None
But how much "spam is None" is different from "spam == None" ?
is() function makes comparaison of (abstract representation of) adresses
of objects in memory. Comparing addresses of objects is a low level
feature performed by low level langages such as C but seldom needed in
high level languages like Python, isn'it ?
More information about the Python-list
mailing list