[GRASS-dev] [GRASS GIS] #1832: Python scripts are with mixed tabs and spaces

GRASS GIS trac at osgeo.org
Tue Apr 9 05:57:55 PDT 2013


#1832: Python scripts are with mixed tabs and spaces
-------------------------+--------------------------------------------------
 Reporter:  klo          |       Owner:  grass-dev@…              
     Type:  defect       |      Status:  new                      
 Priority:  normal       |   Milestone:  6.4.3                    
Component:  Python       |     Version:  unspecified              
 Keywords:  indent       |    Platform:  Unspecified              
      Cpu:  Unspecified  |  
-------------------------+--------------------------------------------------

Comment(by zarch):

 Replying to [comment:8 hamish]:
 > Replying to [ticket:1832 klo]:
 > > Mixing tabs and spaces is not good idea:
 > > http://www.python.org/dev/peps/pep-0008/#tabs-or-spaces
 >
 > annoyingly, it asserts it is so but does not explain why. is it just
 that
 > lots of people submit code after editing with braindead text editors,
 > or is it something inherent in the python language which makes it so...?

 The problem is the inconsistency.

 Python cleaned the syntax as much as possible, and use the space to define
 the code block, using a mixed code can cause troubles [0,1] because you
 are not consistent, and it is prone to errors.
 Moreover in python3 file with mixed syntax will not work.

 Personally I think that we must choose the style to use and add pre-commit
 check consistently.

 Using tabs to indent make problems when you want to aligned with opening
 delimiter, like:

 {{{
 #!python
 # Aligned with opening delimiter
 foo = long_function_name(var_one, var_two,
                          var_three, var_four)
 }}}

 With spaces you are sure that the code look the same for all the
 developers and not affect external source code viewers (e.g. the likes of
 github, pastebin, etc).


 Pietro


 [0] http://www.jroller.com/larrywilliams/entry/mixing_tabs_and_spaces_in
 [1] http://enjoydoingitwrong.wordpress.com/2009/03/24/mixing-tabs-and-
 spaces-in-python/

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/1832#comment:9>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list