On 3/6/06, Bryan Olson <[EMAIL PROTECTED]> wrote:
Peter Hansen wrote:
> The archives could tell you more, but basically on is usually interested
> in *identity* with a singleton object (None), not in whether the object
> on is examining happens to compare equal.  A custom object could be
> designed to compare equal to None in certain cases, even though it *is
> not* None, leading to the "== None" approach being defective code.

But if a custom class allows instances to compare as equal to None,
we might reasonably expect the programmers had a reason. There's not
much anyone can do with None besides passing it around and comparing
it by value or identity. Insisting on 'is' rather than '==' will break
whatever polymorphism such a custom object was trying to achieve.

I agree. None is an object! If you want to compare an object to another object
why not using "=="?

Cyril


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to