Indenting with tabs vs spaces

Ron Stephens rdsteph at earthlink.net
Thu Nov 22 21:28:09 EST 2001


OK, now you all have got me worrying about a new thing. All  my code so far is
indeented with single tabs (four spaces I think). Since I use IDLE or sometimes
PythonWin when I code, will my tabs screw up anyone else trying to run my code?
H9ow about if I use Windows Notepad?

I hate spaces, like tabs.


Peoter Veili wrote:

> > >Tabs are wrong, because different editors will treat them differently.
> > >
> > >Spaces are right, because a space is a space is a space, everywhere you
> > >go.
>
> 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.  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....







More information about the Python-list mailing list