Subject: Re: Python comparision: you sure about that?
From: "Johan Sundström (Achtung Liebe!) @ Pike (-) importmöte för mailinglistan" <6341@lyskom.lysator.liu.se>
Date: Sat, 9 Feb 2008 AD 10:25:01 -0500

It's useful for things like arbitrary-precision bandwidth limiters.
Not your most common application, but useful in those few cases.
Probably less common still is the use case where "Hello" / 3 == ({
"Hel" }) is what you really inended (analogous to how 10 / 3 == 3,
though nevertheless a likely candidate for bugs -- and, as it's an
operator, you can't send parameters to say you really wanted ({ "Hel",
"lo" }) for which you would have needed to use "Hello" / 3.0 instead,
which doesn't truncate the answer (just like how 10 / 3.0 doesn't, or
doesn't much, anyway).

This, and that it's harder to lookup the docs for / than String.split
or similar, probably illustrates several of the pros and cons of using
operators for things. Very convenient, when you know what you do, and
rather painful, when you come across buggy code written by someone who
did not. It's hell to grep for operator induced bugs in a big codebase
and less so to grep for all occurrences of This.big.ugly.boilerplate()
type API. :-)

Return to results