← All posts tagged tabs_vs_spaces

atommixz
code tabs_vs_spaces Python
Почему пробелы в Python это плохо?
вот пример:
…
	…
	много блоков
	…
		def someFunc():
			if 
				…
				много-много блоков
				…
			return True

В этом случае сложно сопоставить if с return, если редактор не поддерживает представление пробелов как табы. Не все редакторы это поддерживают или это нужно настраивать (костыли) В случае если всё представляется табами, то сопоставить эту конструкцию становится черезвычайно просто в любом редакторе.

Между прочим, создатель Gentoo, а ныне создатель Funtoo предпочитает табы пробелам, чего и всем настоятельно желает.

из http://www.funtoo.org/wiki/Coding_Standards:
Tabs vs. Spaces
Tabs and spaces had a fight. Tabs won. They're easier to deal with and allow configurable indentation for those who require it. I don't care what some other group or organization says the convention is. If you don't want to use tabs because you want all your end-of-line comments to line up beautifully, then I have a solution: don't use end-of-line comments (see the next section) and you'll be fine.

Comments
Add comments that provide some insight into your code, and that help to provide context. Also, because we use tabs, place comments on their own lines, separate from source code, ideally separated by a blank line above and below unless you are verbosely commenting every line of code. This also encourages longer, more descriptive comments that may span multiple lines. If you span multiple lines, use a consistent right margin of 160 characters. Comments help you understand your code when you come back to it a year later, so you are adding descriptive comments for yourself as much as for others. Include information you would find helpful if you had a sudden case of amnesia. They are especially important for free/open source software that needs to be maintained by various people over the years.