Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '-*-': 0.07; 'parsing': 0.07; 'python': 0.09; 'instance.': 0.09; 'lines:': 0.09; 'encoding': 0.15; 'file,': 0.15; 'backward': 0.16; 'declaration': 0.16; 'directive': 0.16; 'encodings': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'indent': 0.16; 'set,': 0.16; 'subject: \n ': 0.16; 'subject:fails': 0.16; 'subject:when': 0.16; 'tabs': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'code.': 0.20; 'received:209.85.214.174': 0.21; 'setting': 0.26; 'am,': 0.27; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:/': 0.28; "d'aprano": 0.29; 'editors': 0.29; 'indentation': 0.29; 'spaces': 0.29; 'steven': 0.29; 'character': 0.29; 'source': 0.29; 'code': 0.31; 'could': 0.32; 'mixed': 0.33; 'to:addr:python-list': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'consistent': 0.35; 'nov': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'subject: (': 0.36; 'turn': 0.36; 'editor': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'respect': 0.63; 'worth': 0.63; 'of:': 0.65; "else's": 0.84; 'subject:else': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=o+teSgrIY/690Rze3jloQuKME37pbF3M/c+WHd7u4FE=; b=Ma6OB/88nAGSVjCXN/t5YSBravBHNnux6aIEP8lvGG5mJxBgzoT5ehorZDoEBIVWJ7 eFAs4jeBV6xkpyvSVv+tk3y3/wLQPTVXTPw1jh0HGqXxaUJmiQ5iND8QWGTgysg8c8C3 wfEC2d/lzIu+PNaZ1juzZlCqBGp5UtXgN5pYnBs6qM8uX/HbGhpFS/JZnIZrqyw2r7hW 5AzGb1HldiKy6vG+5b9Uf2II68GpGrnWygxy78XXNsD1TWU6zUY3KCCVmK89IuH5GbX2 qnolJvGtJFtznaGaPhNeiSRMZ97exfPEEyfLbH5n3mt8VHNvzBCLx4pTqXDusagan06K lryw== MIME-Version: 1.0 Date: Thu, 29 Nov 2012 10:04:55 +1100 Subject: Tabs/spaces for indentation (was Re: re.search when used within an if/else fails) From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354143899 news.xs4all.nl 6901 [2001:888:2000:d::a6]:55914 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34041 On Thu, Nov 29, 2012 at 8:39 AM, Steven D'Aprano wrote: > Perhaps it would be nice if Python honoured a directive setting indent > style to spaces or indents, as it honours source code encoding lines: > > # -*- indent: -*- > > Where could be one of: > > space[s] Only accept spaces in indentation > tab[s] Only accept tabs in indentation > mixed Accept "mixed" tabs and spaces, but only if consistent > > with mixed the default for backward compatibility. I don't know that it needs to be a declaration like that; character encodings are critical to parsing the file, but newline-followed-by-tab and newline-followed-by-space are unambiguous. But it would be of value to have something like that, as editors could then be configured to respect it - set the editor to turn tab-key into N spaces but only if "indent tab" is not set, for instance. The question is, is it worth it? The main value would be when you're editing someone else's code. ChrisA