Ian Kelly <ian.g.ke...@gmail.com>: > For somebody reading one of these uses of unary plus in real code, I > imagine it would be a bit of a WTF moment if it's the first time > they've encountered it. I don't recall ever seeing any code that > actually used this, though.
What I don't understand is why there is a unary + but no unary /: -x ≡ 0 - x +x ≡ 0 + x /x ≡ 1 / x //x ≡ 1 // x *x ≡ 1 * x You could write: r = //(//r1 + //r2 + //r3) for r = 1 // (1//r1 + 1//r2 + 1//r3) Actually, the real question is, is the unary - *really* so useful that it merits existence or is it just something that was mindlessly copied into programming languages from elementary school arithmetics? BTW, Scheme's got the whole set: (- 3) => -3 (- 3 2) => 1 (- 3 2 1) => 0 (/ 3) => 1/3 (* 3) => 3 (*) => 1 However, there's a tricky discontinuity: (apply - 3 '(2 1)) => 0 (apply - 3 '(2)) => 1 (apply - 3 '()) => -3 Marko -- https://mail.python.org/mailman/listinfo/python-list