conventions/requirements for 'is' vs '==', 'not vs '!=', etc
Lie
Lie.1296 at gmail.com
Wed May 21 14:23:58 EDT 2008
On May 20, 2:39 am, destroooooy <destrooo... at gmail.com> wrote:
> I'm wondering what is the canonical usage of the keywords 'is' and
> 'not' when you're writing conditionals and loops. The one I've been
> following is completely arbitrary--I use the symbols '==', '!=' for
> numerical comparisons and the words 'is', 'not' for everything else.
>
> Thanks in advance!
If we're talking in English, it would be like this:
There is a person with a black hair called A
There is another person with a black hair called B
A has a nickname C
All of these statements are true:
A.haircolor == B.haircolor
A is C
but this is NOT true:
A is B # is False
and this is debatable:
A == B
whether A is similar enough to B so that they can be said to be equal
is debatable and depends on the purpose of the comparison (which is
why equality comparison is overridable while identity comparison is
not).
More information about the Python-list
mailing list