On Sep 9, 2008, at 9:34 PM, Mike Hansen wrote: > Hi Justin, > >> What's the difference between "==" and "is" (or, more to the point: >> where is this discussed)? > > This is a Python thing as "==" is equality testing and "is" is memory > address testing. For example, > > sage: a = 2 > sage: b = 2 > sage: a == b > True > sage: id(a) > 54737440 > sage: id(b) > 54735856 > sage: a is b > False > > In Python, None, True, and False are all unique so you should use "is" > with them since it is just a pointer check.
It's even worse with Sage, because == tries to do coercion (and fails by raising an exception) so stuff like RR['x'](1) == 1 works. See http://trac.sagemath.org/sage_trac/ticket/4100 for a fix, which makes the (valid I believe) assumption that None is not equal to any Sage element. - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---