Re: Is vs Equality Operator

2008-05-01 Thread Terry Reedy
"Good Z" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Hello, | I am having problem in using is. Here is what i am doing. | | x='' | if x is None or x is '': |return 1 x is not the singleton value None, nor is it the newly created null string object. It is up to the imp

Re: Is vs Equality Operator

2008-05-01 Thread Michael Mabin
'is' tests for identity (variable references the same memory location) while '==' tests for equality. Though it's probably best to use 'is' with more complex classes and not the simpler built-in types like integers. See how 'is' works for lists below: >>> l1 = [1,2,3,4] >>> l3 = [1,2,3,4] >>> l1

Re: Is vs Equality Operator

2008-05-01 Thread Christian Heimes
Good Z schrieb: > Hello, > I am having problem in using is. Here is what i am doing. > > x='' > if x is None or x is '': > return 1 > > The above statement does not return value 1. > > If i changed the above check to > if x == None or x == '': > return 1 > Now it works fine. >

Re: Is vs Equality Operator

2008-05-01 Thread Gary Herron
Good Z wrote: Hello, I am having problem in using is. Here is what i am doing. Short answer: Use == for equality.Don't use "is". Ever! (Especially if you are a newbie.) Longer answer: In a dozen years of programming Python, the only time I use "is" is when testing for something like

Is vs Equality Operator

2008-05-01 Thread Good Z
Hello, I am having problem in using is. Here is what i am doing. x='' if x is None or x is '': return 1 The above statement does not return value 1. If i changed the above check to if x == None or x == '': return 1 Now it works fine. Any idea. What is happening here. I am usin