Re: Comparisons and singletons

2006-03-26 Thread David Isaac
Alan asked: > > 2. If I really want a value True will I ever go astray with the test: > > if a is True: > > >>> a = True > > >>> b = 1. > > >>> c = 1 > > >>> a is True, b is True, c is True > > (True, False, False) "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I th

Re: Comparisons and singletons

2006-03-25 Thread Felipe Almeida Lessa
Em Sáb, 2006-03-25 às 09:11 -0800, Ziga Seilnacht escreveu: > Python has a special internal list of integers in which it caches > numbers smaller than 1000 (I'm not sure that the number is correct), > but that is an implementation detail and you should not rely on it. By testing: >>> a = 10 >>> b

Re: Comparisons and singletons

2006-03-25 Thread Ziga Seilnacht
David Isaac wrote: > "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > >>> a = 1 > > >>> b = 1 > > >>> a == b > > True > > >>> a is b > > False > > Two follow up questions: > > 1. I wondered about your example, > and noticed > >>> a = 10 > >>> b = 10 > >>> a

Re: Comparisons and singletons

2006-03-25 Thread Chris Mellon
On 3/25/06, David Isaac <[EMAIL PROTECTED]> wrote: > "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > >>> a = 1 > > >>> b = 1 > > >>> a == b > > True > > >>> a is b > > False > > Two follow up questions: > > 1. I wondered about your example, > and noticed >

Re: Comparisons and singletons

2006-03-25 Thread David Isaac
"Ziga Seilnacht" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >>> a = 1 > >>> b = 1 > >>> a == b > True > >>> a is b > False Two follow up questions: 1. I wondered about your example, and noticed >>> a = 10 >>> b = 10 >>> a is b True Why the difference? 2. If I really w

Re: Comparisons and singletons

2006-03-25 Thread Ziga Seilnacht
Steven Watanabe wrote: > PEP 8 says, "Comparisons to singletons like None should always be done > with 'is' or 'is not', never the equality operators." I know that "is" > is an identity operator, "==" and "!=" are the equality operators, but > I'm not sure what other singletons are being referred t

Comparisons and singletons

2006-03-25 Thread Steven Watanabe
PEP 8 says, "Comparisons to singletons like None should always be done with 'is' or 'is not', never the equality operators." I know that "is" is an identity operator, "==" and "!=" are the equality operators, but I'm not sure what other singletons are being referred to here. Also, I've seen code t