Operator symbol for "nb_intdivide"

Guido van Rossum guido at zope.com
Fri Jul 27 08:43:01 EDT 2001


> > I don't believe this.  If you can't distinguish / from //, you need
> > new glasses. :-)
> 
> Hmmmm.  Not sure I believe this; mistaking "|" for "||" is said to be
> a frequent cause of errors in C code.

For different reasons: they have different priorities but their
meaning is related (both are "or", just one is bitwise and the other
is Boolean shortcut).  Programmers coming from languages where only
"|" existed were tempted to use that, but the priorities are so broken
that a==b | c==d is parsed as (a == (b|c)) == d.

A better analogy would be = vs. == in C.

But I've never heard of confusion between + and ++ or between - and
--, so I think the psychology of this mistake more complicated than
just the doubling of the symbol.  I know I've made the = vs. ==
mistake even in Python.  Possibly it's more likely because = is by far
the most common symbol.

--Guido van Rossum (home page: http://www.python.org/~guido/)




More information about the Python-list mailing list