All leading tabs or all leading spaces - why isn't that enforced?

Discussion in 'Python' started by John Nagle, Aug 7, 2007.

  1. John Nagle

    John Nagle Guest

    One can argue over tab vs. space indentation, but mixing the two
    is just wrong. Why not have CPython report an error if a file has
    both leading tabs and leading spaces? I know that was proposed at
    some point, but I don't think it ever went in. That would catch a
    common error introduced during maintenance.

    John Nagle
    John Nagle, Aug 7, 2007
    1. Advertisements

  2. John Nagle

    Steve Holden Guest

    I suppose we Pythonistas are just too permissive for our own good.
    Consider the opportunity to use mixed tabs and spaces a piece of rope of
    your preferred length ...

    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC/Ltd
    Skype: holdenweb
    --------------- Asciimercial ------------------
    Get on the web: Blog, lens and tag the Internet
    Many services currently offer free registration
    ----------- Thank You for Reading -------------
    Steve Holden, Aug 7, 2007
    1. Advertisements

  3. John Nagle

    Omari Norman Guest

    I suppose we Pythonistas are just too permissive for our own good.
    I thought I remembered reading somewhere that Python 3000 will ban tabs
    as indentation characters, but now I can't turn up a link for it...
    Omari Norman, Aug 7, 2007
  4. John Nagle

    Neil Cerutti Guest

    Tabs are going to be banned in the C Style Guide for Python 3000
    source code, but they aren't being banned from Python 3000 code.
    Neil Cerutti, Aug 7, 2007
  5. John Nagle

    James Antill Guest

    While I agree it should be default, you can enable extra checking with
    -tt. Eg.

    % jhexdump /tmp/
    0x00000000: 2321 202F 7573 722F 6269 6E2F 7079 7468 #! /usr/bin/pyth
    0x00000010: 6F6E 202D 7474 0A0A 6966 2054 7275 653A on -tt..if True:
    0x00000020: 0A09 7072 696E 7420 2261 220A 2020 2020 ..print "a".
    0x00000030: 2020 2020 7072 696E 7420 2262 220A print "b".
    % /tmp/
    File "/tmp/", line 5
    print "b"
    TabError: inconsistent use of tabs and spaces in indentation
    % python /tmp/

    ....note that this doesn't require all spaces or all tabs, just that
    their usage has to be consistent.
    James Antill, Aug 7, 2007
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.