On 3/25/06, David Isaac <[EMAIL PROTECTED]> wrote:
> "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > >>> a = 10000
> > >>> b = 10000
> > >>> 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 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)
>

None, True, and False are all singletons and should be compared with
"is". There are some other singletons - small integers (up to 10, I
believe) as well as the empty string. However, I am not sure (and I am
sure someone will correct me if I'm wrong) but I believe that these
are not specified as singletons, and that it's an implementation
detail that they are.

> Thanks,
> Alan Isaac
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to