Re:PM of Singapore Shares His C++ Sudoku Solver Source Code
by steinnes on Monday May 04, 2015 @07:27AM
(#9485484)
You would be happy to have a person who mixes tabs and spaces as your PM? ... mixes tabs and spaces. Argh.
[ Parent
| on HN ]
Re:PM of Singapore Shares His C++ Sudoku Solver Source Code
by naz on Monday May 04, 2015 @07:51AM
(#9485566)
That's a pretty common style in C++. If he were a Ruby programmer and did that, then I'd be less happy.
Re:PM of Singapore Shares His C++ Sudoku Solver Source Code
by damcedami on Monday May 04, 2015 @08:06AM
(#9485609)
That's pretty common style in Ruby. If he were a Python programmer and did that, then I'd be super unhappy.
Re:PM of Singapore Shares His C++ Sudoku Solver Source Code
by FreeFull on Monday May 04, 2015 @08:23AM
(#9485679)
Python doesn't even allow tabs by default, does it?
Re:PM of Singapore Shares His C++ Sudoku Solver Source Code
by rjaco31 on Monday May 04, 2015 @08:37AM
(#9485724)
You can use tabs and spaces, you can even use both without any problem. However, your indentation has to be coherent along the whole file. So you can use as your indentation pattern "4 spaces", "one tab", "2 spaces", "one tab + 2 spaces", but you can never change your pattern in the middle of the file, once you have chosen one pattern, you have to keep this one till the end of the file or it'll throw an indentation error.
But in reality, you should indeed stick with the "4 spaces" PEP8 compliant style.
Re:PM of Singapore Shares His C++ Sudoku Solver Source Code
by dagw on Monday May 04, 2015 @08:47AM
(#9485773)
once you have chosen one pattern, you have to keep this one till the end of the file or it'll throw an indentation error.
Only if the resulting indentation is an actual error. It's quite possible that the parser's interpretation of resulting indentation is a valid program with different semantics than you intended.
Re:PM of Singapore Shares His C++ Sudoku Solver Source Code
by pjc50 on Monday May 04, 2015 @08:39AM
(#9485733)
It does, and it doesn't warn you if you have both, it just breaks your program.
Re:PM of Singapore Shares His C++ Sudoku Solver Source Code
by acveilleux on Monday May 04, 2015 @09:11AM
(#9485890)
Python 2 does, Python 3 does not:
> TabError: inconsistent use of tabs and spaces in indentation
Note for pedant: Yes, you can mix tabs and spaces in Python3, but only if you do it absolutely consistently for the block and all sub-block.