Bug in % string formatting?

Jeff Shannon jeff at ccvcorp.com
Fri Dec 21 13:50:43 EST 2001


Michael Hudson wrote:

>
> > The reason is because % is also the modulo division operator.
>
> Which is in turn a reason for not overloading operators too much.
> Anyone ever done this:
>
> cout << var ? "true" : "false";
>
> in C++?  It was *years* before I realised why that didn't work...

There's a reason that I tend to throw in lots of extra parenthesis.  :)  (I
don't know the precedence in the above case, but I would've thrown the ?:
clause in parens just on general principles.)  Besides, even when I know that
the operator precedence works right without parens, it makes the intent a
little more clear in most cases, by visually grouping subexpressions
together.  Well, at least until you get so many subexpressions that it starts
looking like Lisp.... ;)

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list