Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail 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; 'that?': 0.05; 'column': 0.07; 'diff': 0.07; 'error:': 0.07; 'python3': 0.07; 'character,': 0.09; 'identifier': 0.09; 'measure': 0.09; 'parsing': 0.09; 'properly.': 0.09; 'spaces': 0.09; 'width': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'def': 0.12; '(within': 0.16; '*any*': 0.16; '9:13': 0.16; 'bytes).': 0.16; 'cares': 0.16; 'eof': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'involved;': 0.16; 'mapped': 0.16; 'outputs': 0.16; 'renders': 0.16; 'simplest': 0.16; 'syntaxerror:': 0.16; 'tab': 0.16; 'tabs': 0.16; 'unexpected': 0.16; 'width,': 0.16; 'width.': 0.16; 'zero,': 0.16; 'weird': 0.16; 'ignore': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'file,': 0.19; 'input': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'certainly': 0.24; 'scroll': 0.24; 'file.': 0.24; '(or': 0.24; '---': 0.24; 'cc:2**0': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'chris': 0.29; 'character': 0.29; 'generally': 0.29; 'characters': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(which': 0.31; 'code': 0.31; 'easier': 0.31; 'lines': 0.31; '"",': 0.31; 'gcc': 0.31; 'file': 0.32; 'there.': 0.32; 'text': 0.33; 'open': 0.33; 'beginning': 0.33; 'could': 0.34; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'reports': 0.37; 'wrong': 0.37; 'expected': 0.38; 'displays': 0.38; 'pm,': 0.38; 'visual': 0.39; 'sure': 0.39; 'enough': 0.39; 'how': 0.40; 'even': 0.60; 'simply': 0.61; 'times': 0.62; 'more': 0.64; 'positions': 0.67; 'overall': 0.69; 'eight': 0.74; 'jul': 0.74; 'counts': 0.83; 'abc': 0.84; 'actually,': 0.84; 'column.': 0.84; 'improved.': 0.84; 'significance': 0.84; 'to:none': 0.92 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:content-transfer-encoding; bh=J+8E4eEOqM7OEaJ+2Bm7BZ5j4G17HAAhExvQ8kz9j2o=; b=OKaqnMf9BG2hInBDohflDFsMqCIFS6768guZCaoM1zxJ2/kvgyWCiwXJM69qWsxv+A UsuW3+50bgiGLUFMnzTfgAv0k6QVBJji9Fn4ivaf39Kx/eGD0WCyTwQnC4OIgpHlPKAX ZkDtd0y9vDu2bjHz/EK4RmjNyq0CYefMgAH3CqA5F5pfv3Ajdn3LO/LCl27Mdf8KNZGz RgLU+VxjOXASXWvO4Bk9lZUSx0WBzCccS3nx06tKRzt7CF+yfKSZ3SODvjcDO+55F/Nk fuEXVzzqAcADWvPx02mkK2K6VgYRmGqi/Go9Pv/XG3IvoVbRiIw6Xp1xrbXbiVhuYpcL sfew== MIME-Version: 1.0 X-Received: by 10.52.189.161 with SMTP id gj1mr27855453vdc.2.1404819460522; Tue, 08 Jul 2014 04:37:40 -0700 (PDT) In-Reply-To: <874mysgl2y.fsf@elektro.pacujo.net> References: <53B59358.2040404@tobiah.org> <53bbb047$0$2926$c3e8da3$76491128@news.astraweb.com> <87a98kgqsm.fsf@elektro.pacujo.net> <874mysgl2y.fsf@elektro.pacujo.net> Date: Tue, 8 Jul 2014 21:37:40 +1000 Subject: Re: PEP8 and 4 spaces From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 73 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404819468 news.xs4all.nl 2932 [2001:888:2000:d::a6]:42755 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74165 On Tue, Jul 8, 2014 at 9:13 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> Not quite; tools like diff that put a character at the beginning of >> the line are likely to be tab-aware, > > No, just tried it again: diff outputs tabs as tabs. > > $ diff abc def > 1,2c1,2 > < abc > < abc > --- > > def > > def > > where line 1 begins with a tab and line 2 begins with 8 spaces in each > file. Check out its -t and -T options; diff is definitely tab-aware. >> and gcc is certainly going to comprehend them > > $ gcc -c test.c > test.c:1:2: error: expected identifier or =E2=80=98(=E2=80=99 at end o= f input > > where test.c contains > > ( > > IOW, gcc reports that the open parenthesis is in column 2. It's easier to number the positions that way, in the same way that you would number lines - by how many times you have to hit down or right arrow to get there. In my MUD client, I measure text positions in characters (within a line; a particular position is identified by (line, char), because lines are generally far more important than overall positions), even when tabs are involved; a tab simply counts as one character, even though it displays as up to eight times the width. Actually, I'm currently contemplating a reworking of how that's all mapped out, which would mean that *any* character is allowed to take up *any* width, including zero, in which case the only significance is that a tab takes up a variable width depending on where it is in the line (which is already coped with). >> And I think less takes notice of them, too, > > How? Shrink your terminal down to some weird width like 45, create a file with long lines including tabs, 'less' the file, and use the right arrow key to scroll horizontally. It takes note of tabs and renders them properly. >> so it's only the very simplest tools like cat that actually ignore >> them or treat them as single characters (or even bytes). > > They all seem to be "simple." At least Python is: > > $ python3 -c 'print (' > File "", line 1 > print ( > ^ > SyntaxError: unexpected EOF while parsing > > where the caret is pointing at the wrong visual column. If someone cares enough to write a patch, I'm sure the traceback renderer could be improved. But how many people actually use tabs inside code like that? ChrisA