Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Problems using struct pack/unpack in files, and reading them. Date: Sat, 14 Nov 2015 18:52:56 +0200 Organization: A noiseless patient Spider Lines: 53 Message-ID: <87vb94ikuv.fsf@elektro.pacujo.net> References: <20151113192045.GA9913@z-sverige.nu> <56469f14$0$1612$c3e8da3$5496439d@news.astraweb.com> <5646c95a$0$1597$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="25912"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+VEqBG75pvgsOdx7ejcezR" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:JPKCN8POXpohlGPwW9baDIt+ZlY= sha1:tffCqVJjlgszTAnpIJxuE6owiBg= Xref: csiph.com comp.lang.python:98816 Ian Kelly : > 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