Tabs/spaces for indentation (was Re: re.search when used within anif/else fails)

Discussion in 'Python' started by Chris Angelico, Nov 28, 2012.

  1. 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: <mode> -*-
    >
    > Where <mode> could be one of:
    >
    > space Only accept spaces in indentation
    > tab 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
     
    Chris Angelico, Nov 28, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ibloom
    Replies:
    12
    Views:
    912
    Bruno Desthuilliers
    Feb 13, 2008
  2. rantingrick

    Tabs -vs- Spaces: Tabs should have won.

    rantingrick, Jul 16, 2011, in forum: Python
    Replies:
    95
    Views:
    1,885
    Roy Smith
    Jul 19, 2011
  3. Abby Lee
    Replies:
    5
    Views:
    442
    Abby Lee
    Aug 2, 2004
  4. Jesse B.
    Replies:
    2
    Views:
    201
    Josh Cheek
    Mar 27, 2010
  5. Kevin T
    Replies:
    17
    Views:
    242
    Prasad, Ramit
    Nov 29, 2012
Loading...

Share This Page