[GRASSGUI] Using Python -t ?
Glynn Clements
glynn at gclements.plus.com
Tue Mar 20 12:58:39 EDT 2007
Jachym Cepicky wrote:
> I do not have clear opinion to this. Till now, I was using 4 letters.
> Grass default should be 8. It is truth, that 4 letters sound
> reasonable, because you lost only half of the space in the line, which
> you wold loose, if the indentation would be set to 8
Don't confuse the indentation step with the width of a tab.
Indenting in multiples of 4 columns is reasonable, but that doesn't
change the fact that tab stops are every 8 columns; this is hard-coded
into Python:
http://docs.python.org/ref/indentation.html
First, tabs are replaced (from left to right) by one to eight
spaces such that the total number of characters up to and
including the replacement is a multiple of eight (this is
intended to be the same rule as used by Unix). The total
number of spaces preceding the first non-blank character then
determines the line's indentation. Indentation cannot be split
over multiple physical lines using backslashes; the whitespace
up to the first backslash determines the indentation.
If you only ever use tabs for indentation, then it doesn't really
matter what your editor thinks the width of a tab is. But if you use a
mixture of spaces and tabs, you have to bear in mind that Python will
treat a tab as 8 spaces.
> class MyClass:
> def MyFunction():
> if 1:
> #my condition
> while 1:
> #my loop
>
> class MyClass:
> def MyFunction():
> if 1:
> #my condition
> while 1:
> #my loop
>
> We should IMHO set one-line definiton for vim and emacs to each
> python file, which would tell them, how the indentation is set.
>
> for vim, this would be
> ## vim:ts=4:et:sts=4:sw=4:ai:
The ts=4 is bogus; it should be ts=8. sts=4 and sw=4 are okay.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-gui
mailing list