Indenting with tabs vs spaces

John Roth johnroth at ameritech.net
Thu Nov 22 12:04:03 EST 2001


"Peoter Veili" <peoter_veliki at hotmail.com> wrote in message
news:mailman.1006387828.11756.python-list at python.org...

> Indenting with tabs can be done such that it will look the same on
every
> editor that uses fixed-width fonts, meaning everything will line up
> correctly, it least in the sense that really matters.  Here's an
example of
> what I mean:
>
>
>
>     function helloThere("hello",
>                                        "there"){
>     }
>
>
> The proper way to do this is the second line needs to be typed with
one tab
> followed by enough spaces to line up the "hello" and "there".  This
way the
> "hello" and "there" will line up correctly on any editor. If the
person was
> lazy and tabbed all the way out to right before "there" and then
filled in
> with a
> few spaces, it may not line up depending on what your tabwidth is set
to.
>
> Besides this I know of no problems with using tabs.

The trouble with this is that all of your tools need to agree on where
the tab stops are set. In the example above, you probably used four
character tabs, and the tool you used formatted it as 8 character tabs.
(At least, it looks that way to me.) If you disagree with the
interpreter,
you've lost it. In particular, if you try using four character tabs, and
the
Python interpreter thinks you are using 8 character tabs, you're going
to
have lots of indentation errors that your editor won't show.


> I find them cleaner and
> more efficient.  I'd rather tab 10 times than hit the space bar 40
times. I
> never have to go through a whole file and manually line things up
because at
> one place in the file I accidentally didn't indent with the right
amount of
> spaces and half the file needs fixing.  Auto-indent helps, but
still....

A good syntax aware editor does all of this for you. If you're arguing
with your editor, you can:

1. get a new editor you agree with
2. find another job where you can use the editor of your choice,
3. get over it.
4. suffer.

John Roth
>
>
>
>
>





More information about the Python-list mailing list