Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Problems using struct pack/unpack in files, and reading them. Date: Sun, 15 Nov 2015 03:59:57 +1100 Lines: 40 Message-ID: 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 X-Trace: news.uni-berlin.de gOIf8LLY4y5SqrGA2rb62g8/7pH3y16pdw7V39MVWaKA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'received:209.85.223': 0.03; 'binary': 0.05; 'builtin': 0.07; 'continuation': 0.07; 'cc:addr:python-list': 0.09; '===========': 0.09; 'backslash': 0.09; 'inclusion': 0.09; 'minus': 0.09; 'stealing': 0.09; 'subject:files': 0.09; 'subject:using': 0.09; 'will,': 0.09; 'python': 0.10; '(but': 0.15; 'argument': 0.15; 'section.': 0.15; '+feature': 0.16; '465': 0.16; '``+``': 0.16; '``-``': 0.16; 'bitwise': 0.16; 'cc:name:python': 0.16; 'confusion': 0.16; 'did).': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hypothetical': 0.16; 'integers.': 0.16; 'language:': 0.16; 'negation': 0.16; 'operator.': 0.16; 'preamble': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'something.': 0.16; 'stuff.': 0.16; 'subject:Problems': 0.16; 'unary': 0.16; 'wrote:': 0.16; 'library': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'skip:= 20': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'turns': 0.27; '"please': 0.29; '13,': 0.29; 'does,': 0.29; 'motivation': 0.29; 'operators': 0.29; 'pep': 0.29; 'types.': 0.29; 'subject:/': 0.30; '15,': 0.30; 'e.g.': 0.30; 'push': 0.30; 'probably': 0.31; "d'aprano": 0.33; 'steven': 0.33; 'languages': 0.34; 'add': 0.34; 'received:google.com': 0.35; 'text': 0.35; 'done': 0.35; 'nov': 0.35; 'something': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'doing': 0.38; 'version': 0.38; 'received:209': 0.38; 'anything': 0.38; 'skip:p 20': 0.38; 'where': 0.40; 'some': 0.40; 'details': 0.62; 'due': 0.65; 'here': 0.66; 'chrisa': 0.84; 'dsl': 0.84; 'subject:pack': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=7YnpUzm2gFEPLglb9ovU6mb1+hcwzqmhblp9Kf0A6z8=; b=UnZw4K0V+A4uUKcffu1qqV85ZIddCILQy0I6XptTJDATg/Fz9NyRNq/APWU09WPW0w UWM++1lIYLZVB0xMYlBSg61SV4HKCrT0sPz2uO3Rqu7gxo+b6KCZGkNv+xqZB0i95Vkc /wij3dH++DfxtXITZaolwdm9380oSGI13L0LPy9fBpf4e3PMan71ImAec7xiN99AIyOe mXeWS93S2BoC+RFaeNTGukUixhAH0qYkwZMk6NbeYotsrqis4dxniL4AKTewgE09ezR1 Hf1TW0cI5/f/95+GXEw/JMJFTOkfX1rh0BlPfaQqUvhKICZpbLk3VV/tOHEjJyebWZj/ zTOA== X-Received: by 10.107.16.84 with SMTP id y81mr24056900ioi.19.1447520397163; Sat, 14 Nov 2015 08:59:57 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98817 On Sun, Nov 15, 2015 at 2:43 AM, Ian Kelly wrote: > On Fri, Nov 13, 2015 at 10:40 PM, Steven D'Aprano wrote: >> Python has operator overloading, so it can be anything you want it to be. >> E.g. you might have a DSL where +feature turns something on and -feature >> turns it off. > > By that argument we should also have operators ~, !, $, \, ? because > some hypothetical DSL might someday want to use them for something. Unary tilde does, doing bitwise negation on integers. Backslash probably never will, due to confusion with line continuation and stuff. But let's look at the parallel-universe Python in which unary plus never existed (but unary minus did). The PEP preamble for its inclusion says: Abstract This PEP proposes a new unary version of the binary + operator. Specification A new unary operator is added to the Python language: ======= ========================= =========== Op Precedence/associativity Method ======= ========================= =========== ``+`` Same as unary ``-`` ``__pos__`` ======= ========================= =========== No implementations of this methods is added to the builtin or standard library types. However, we foresee that Domain-Specific Languages can make use of this parallel to unary minus; see Intended usage details below for details. Okay. I've done my bit, stealing text from PEP 465. Now Steven, you can write the Motivation section. There's a lot of similarities here (Python's built-in types do not need @ or unary + for anything), but the big push for 465 was that there have been calls for the new operator for years. So... where would the "please add unary plus" calls come from? ChrisA