"/a" is not "/a" ?
steve at pearwood.info
Sat Mar 7 08:34:17 CET 2009
skip at pobox.com wrote:
> Steven> Mutable versus immutable is irrelevant. The complexity of the
> Steven> object is irrelevant. The phase of the moon is irrelevant. The
> Steven> *only* relevant factor is the programmer's intention:
> Which for a new user not familiar with the differing concepts of "is" and
> "==" can lead to mistakes.
Right. And for newbies unfamiliar with Python, they might mistakenly think
that ^ is the exponentiation operator rather than **.
So what do we do? Do we teach them what ^ actually is, or give them bad
advice "Never call ^" and then watch them needlessly write their own
Do we then defend this terrible advice by claiming that nobody needs
exponentiation? Or that only experts need it? Or that it's necessary to
tell newbies not to use ^ because they're only newbies and can't deal with
No, of course not. But that's what some of us are doing with regard to "is".
Because *some* newbies are ignorant and use "is" for equality testing, we
patronisingly decide that *all* newbies can't cope with learning what "is"
really is for, give them bad advice, and thus ensure that they stay
> Steven> If you find it difficult to think of a reason for testing for
> Steven> identity, you're right, there aren't many. Since it's rare to
> Steven> care about identity, it should be rare to use "is". But in the
> Steven> few times you do care about identity, the correct solution is
> to Steven> use "is" no matter what sort of object it happens to be. It
> Steven> really is that simple.
> Right. Again though, when newcomers conflate the concepts they can
> deceive themselves into thinking "is" is just a faster "==".
Then teach them the difference, don't teach them superstition.
More information about the Python-list