0 votes
1 view
in Python by (6.5k points)

I have always used tabs for indentation when I do Python programming. But then I came across a question here on SO where someone pointed out that most Python programmers use spaces instead of tabs to minimize editor-to-editor mistakes.

How does that make a difference? Are there other reasons why one would use spaces instead of tabs for Python? Or is it simply not true?

Should I switch my editor to insert spaces instead of tabs right away or keep on going like I used to?

1 Answer

0 votes
by (107k points)

When you will look in PEP-8 it tells us to use space instead of tab.

  • The spaces are the preferred over tab for indentation method.

  • Tabs should be used solely to remain consistent with code that is already indented with tabs.

  • If you are using Python 3 it does not allow us to mix the use of tabs and spaces for indentation.

  • If you are using Python 2 then you can indent with a mixture of tabs and spaces should be converted to using spaces exclusively.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...