Tabs or spaces? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Tabs or spaces?

So ignoring the fact that you should always use whatever is consistent with the code base that you're working in, what is your preference, tabs or spaces? Personally I use spaces because it is the recommendation in most of the languages I use which makes switching easier.

5th Dec 2016, 7:13 PM
James Durand
James Durand - avatar
4 Answers
+ 2
yep, recommendations for indenting Python code is exactly 4 spaces. but pressing tab 1 time is more convenient than pressing space 4 times. for this most of text editors and IDE's provide functionality to replace tab with specified amount of spaces, so it solves convenience problem
5th Dec 2016, 8:26 PM
Demeth
Demeth - avatar
+ 1
I always used spaces to avoid the way different editors handle the tab characters. I like the Python 4 spaces also and try to do that everywhere i code. That said, if you walk into a project that's already going and has a style guide that says you use tab then you use tab. Don't change style mid-stream to suit your personal preference.
5th Dec 2016, 8:30 PM
Charles Torry
Charles Torry - avatar
+ 1
Tabs. They are easily selectable, removable, placable. The only advantage of whitespaces is that they look the same in all text editors.
5th Dec 2016, 9:21 PM
Ivan G
Ivan G - avatar
0
spaces, as they are a fix measuring unit. when you work on a same code base with other developers, everyone has an idea how much indentation four spaces is. tabs can be replaced/ displayed differently, which is extremely dangerous in Python. have a research on "editorconfig" which makes group projects much easier!
6th Dec 2016, 9:21 PM
codinator
codinator - avatar