Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65562

Re: how to reduce bugs due to incorrect indentation

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.054
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'lines,': 0.07; 'stops': 0.07; 'bug.': 0.09; 'git': 0.09; 'happens.': 0.09; 'spaces': 0.09; 'cc:addr:python-list': 0.11; 'did.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'set,': 0.16; 'tab': 0.16; 'tabs': 0.16; 'unexpectedly': 0.16; 'uses,': 0.16; 'weird': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'commit': 0.19; 'written': 0.21; 'feb': 0.22; '(in': 0.22; 'issue.': 0.22; 'cc:addr:python.org': 0.22; 'replace': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'character': 0.29; "doesn't": 0.30; 'characters': 0.30; 'mix': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; 'accidentally': 0.31; 'another.': 0.31; 'evil': 0.31; 'indentation': 0.31; 'larry': 0.31; 'file': 0.32; 'stuff': 0.32; 'fri,': 0.33; 'guess': 0.33; 'problem.': 0.35; 'but': 0.35; 'received:google.com': 0.35; "didn't": 0.36; 'two': 0.37; 'checks': 0.38; 'depends': 0.38; 'mine': 0.38; 'whatever': 0.38; 'files': 0.38; 'does': 0.39; 'sure': 0.39; 'either': 0.39; 'easy': 0.60; 'catch': 0.60; 'solve': 0.60; 'first': 0.61; 'back': 0.62; "you've": 0.63; 'pick': 0.64; 'more': 0.64; 'different': 0.65; 'chance': 0.65; 'other.': 0.75; 'yourself': 0.78; 'bitten': 0.84; "else's": 0.84; 'fry': 0.84; "it'd": 0.84; 'obvious.': 0.84; 'water,': 0.84; 'water.': 0.84; 'involved.': 0.91; 'oil': 0.91; 'sorry.': 0.91; '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; bh=0/1AxZxQFur31JkDidpUdDhrClTUISdRn8c/+HVJOGg=; b=ghywT+hDE3Th5jNY28wc9CD3HvT3wmqLoJ28ru0gU+zTF5WwBV8rsGxnJnvXYc3AmE z+6DT6vYox32+VKaPg8xgE7j+Wt2d7+mNA8+3YA2Wo9b9VaNfX3iQDytwM2fClWc8/ZA lgOsOEp9Dni4mzIJhSUuhJ5N7stdMo/E7U6a7ohC0SILp05H8u8nsq4VUMZF2eDNaBCJ s1C7L1WC4aUIraNwJ5dYP9ZqMvPtFgxKRbZaNpVHVMEA8wCVNiTVhrowolInpp2PUscd vi/NTUp3KrfAi6A2mCgIQ0YoEz8YeRot8ESliJGtHqxHIkF3Sh1i9be1/tEQ0+OPE9zG w8eg==
MIME-Version 1.0
X-Received by 10.68.108.194 with SMTP id hm2mr15530235pbb.22.1391725817200; Thu, 06 Feb 2014 14:30:17 -0800 (PST)
In-Reply-To <CACwCsY4h4K9knZRkhV=DweCAHiLx4UpmqO2BHT_NFdCqu5MzZg@mail.gmail.com>
References <f63f079f-da05-4f09-ad01-4b764ef16d7f@googlegroups.com> <ld0rb2$5od$1@ger.gmane.org> <CACwCsY780xSMED=Gn-QSvRzbb_Y0=QcJuqfkUS1OVomvE6YRJA@mail.gmail.com> <52F3FF51.3050502@stoneleaf.us> <CACwCsY4h4K9knZRkhV=DweCAHiLx4UpmqO2BHT_NFdCqu5MzZg@mail.gmail.com>
Date Fri, 7 Feb 2014 09:30:17 +1100
Subject Re: how to reduce bugs due to incorrect indentation
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6463.1391725827.18130.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391725827 news.xs4all.nl 2852 [2001:888:2000:d::a6]:48439
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65562

Show key headers only | View raw


On Fri, Feb 7, 2014 at 9:09 AM, Larry Martell <larry.martell@gmail.com> wrote:
> The Tab key is not evil, it's the tab character (Ctrl-I). I have been
> bitten by this many time when I had to work on a program written by
> another. They had their tab stops set at 5 or 6, mine is set at 4, or
> they did not have expandtab set, but I did. So you get either a script
> that looks misaligned, but works, or one that does not look misaligned
> but doesn't work. When I have to pick up someone else's script the
> first thing I do is replace the tabs with spaces.

All you've proven is that *mixing* spaces and tabs is evil. It's like
arguing that oil is evil because, when you mix it with water, weird
stuff happens. But that doesn't mean I want to fry my bacon in water.

Mmm, bacon.

Sorry. I'm back now. Ahem. Arguably, a better fix is to replace spaces
with tabs, because they're more obvious. But mainly, just be
consistent. Whatever one file uses, it uses exclusively. It'd be
pretty easy to create a git commit hook that checks files for leading
indentation and rejects the commit if it's mismatched; I would guess
the same is true in Mercurial.

But none of this would solve the OP's original issue. Whether it's a
tab or spaces, unexpectedly indenting a line of code is a problem.
It's no different from accidentally hitting Ctrl-T in SciTE and
reordering two lines, when one line depends on the other. It's a bug.
So you look at your commits before you make them (to give yourself a
chance to catch it quickly), and you make sure you can always look
back over your commits (in case you didn't catch it quickly). Much
better than blaming the characters involved. Poor innocent U+0009.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

how to reduce bugs due to incorrect indentation msustik@gmail.com - 2014-02-05 19:02 -0800
  Re: how to reduce bugs due to incorrect indentation Dan Sommers <dan@tombstonezero.net> - 2014-02-06 03:08 +0000
    Re: how to reduce bugs due to incorrect indentation Chris Angelico <rosuav@gmail.com> - 2014-02-06 15:47 +1100
  Re: how to reduce bugs due to incorrect indentation Asaf Las <roegltd@gmail.com> - 2014-02-05 21:23 -0800
  Re: how to reduce bugs due to incorrect indentation Terry Reedy <tjreedy@udel.edu> - 2014-02-06 03:09 -0500
  Re: how to reduce bugs due to incorrect indentation Grant Edwards <invalid@invalid.invalid> - 2014-02-06 14:49 +0000
    Re: how to reduce bugs due to incorrect indentation msustik@gmail.com - 2014-02-06 10:51 -0800
  Re: how to reduce bugs due to incorrect indentation Roel Schroeven <roel@roelschroeven.net> - 2014-02-06 21:29 +0100
    Re: how to reduce bugs due to incorrect indentation msustik@gmail.com - 2014-02-06 17:20 -0800
      Re: how to reduce bugs due to incorrect indentation Chris Angelico <rosuav@gmail.com> - 2014-02-07 12:57 +1100
      Re: how to reduce bugs due to incorrect indentation Roel Schroeven <roel@roelschroeven.net> - 2014-02-07 23:08 +0100
      Re: how to reduce bugs due to incorrect indentation Jurko Gospodnetić <jurko.gospodnetic@pke.hr> - 2014-02-08 12:11 +0100
  Re: how to reduce bugs due to incorrect indentation Larry Martell <larry.martell@gmail.com> - 2014-02-06 15:36 -0500
  Re: how to reduce bugs due to incorrect indentation Ethan Furman <ethan@stoneleaf.us> - 2014-02-06 13:32 -0800
  Re: how to reduce bugs due to incorrect indentation Larry Martell <larry.martell@gmail.com> - 2014-02-06 17:09 -0500
  Re: how to reduce bugs due to incorrect indentation Chris Angelico <rosuav@gmail.com> - 2014-02-07 09:30 +1100
    Re: how to reduce bugs due to incorrect indentation Asaf Las <roegltd@gmail.com> - 2014-02-06 15:01 -0800
      Re: how to reduce bugs due to incorrect indentation Chris Angelico <rosuav@gmail.com> - 2014-02-07 11:08 +1100
  Re: how to reduce bugs due to incorrect indentation Roel Schroeven <roel@roelschroeven.net> - 2014-02-07 23:06 +0100

csiph-web