Problems using struct pack/unpack in files, and reading them.
Ian Kelly
ian.g.kelly at gmail.com
Sat Nov 14 12:04:36 EST 2015
On Nov 14, 2015 9:56 AM, "Marko Rauhamaa" <marko at pacujo.net> wrote:
>
> Ian Kelly <ian.g.kelly at 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)
Unary integer division seems pretty silly since the only possible results
would be 0, 1 or -1.
More information about the Python-list
mailing list