Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'subject:Python': 0.06; 'strict': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:> 40': 0.09; 'spaces': 0.09; 'url:github': 0.09; 'width': 0.09; '"pending"': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'tabs': 0.16; 'url:linux': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'header:User-Agent:1': 0.23; 'received:comcast.net': 0.24; '(or': 0.24; 'define': 0.26; 'suggested': 0.26; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'specifically': 0.29; 'thus': 0.29; 'characters': 0.30; 'skip:( 20': 0.30; 'code': 0.31; 'follows': 0.31; 'indentation': 0.31; 'struct': 0.31; 'linux': 0.33; 'says': 0.33; 'worked': 0.33; 'display': 0.35; 'editor': 0.35; 'there': 0.35; 'like,': 0.36; 'skip:> 10': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'up,': 0.60; "you've": 0.63; 'choose': 0.64; 'charset:windows-1252': 0.65; 'subject: & ': 0.68; 'fact,': 0.69; 'manner': 0.72; 'eight': 0.74; 'characters,': 0.84; 'krish': 0.84; 'url:master': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: Tabs for indentation & Spaces for alignment in Python 3? Date: Fri, 05 Dec 2014 21:31:47 -0500 References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: c-50-133-228-126.hsd1.ma.comcast.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417833118 news.xs4all.nl 2869 [2001:888:2000:d::a6]:41386 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:82032 On 12/5/14 8:50 PM, Aahan Krish wrote: > Hello Ned, > > I thought that the use of tabs and spaces in the manner I suggested is > pretty common. Linux Kernel follows the same technique, for example: > https://github.com/torvalds/linux/blob/master/kernel/async.c#L100 > This is a perfect example! The code (with tabs as >--- and leading spaces as .) is: >-------if (!list_empty(pending)) >------->-------ret = list_first_entry(pending, struct async_entry, >------->------->------->-------.......domain_list)->cookie; Now, display it in your editor with tabs set to four spaces: >---if (!list_empty(pending)) >--->---ret = list_first_entry(pending, struct async_entry, >--->--->--->---.......domain_list)->cookie; "domain_list" and "pending" no longer line up, even though the author worked so hard to make the code look nice. In fact, the Linux kernel specifically says that tabs must be eight spaces (https://www.kernel.org/doc/Documentation/CodingStyle): Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3. So you've started by trying to use tabs so that people can choose the indentation width they like, and ended up with a strict rule that you cannot change the size of tabs. -- Ned Batchelder, http://nedbatchelder.com