On Wednesday, July 28, 2010, Carl Witty <carl.wi...@gmail.com> wrote: > On Wed, Jul 28, 2010 at 7:07 PM, William Stein <wst...@gmail.com> wrote: >> On Wednesday, July 28, 2010, kcrisman <kcris...@gmail.com> wrote: >>> But for True and False, we would rather have >>> >>> if n is True: >>> >>> not >>> >>> if n==True: >>> >>> correct? I've seen that cause some problems in code I've reviewed, >>> where things that shouldn't be True were True. >>> >> >> I would use >> >> If n: >> >> If you want to make sure n is a book, do: >> >> if isinstance(n,bool) and n: > > I disagree. I think "n is True" is fine. It works, and it's > documented to work; "bool?" says, > Returns True when the argument x is true, False otherwise. The > builtins True and False are the only two instances of the class bool. > so there can't be any booleans that are true other than True. > > (And "n is True" is going to be vastly faster than "isinstance(n, bool) and > n".)
You're right - I stand corrected. > > Carl > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org > -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org