Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (7.3k 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 (106k 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
0 answers
0 votes
1 answer
asked Nov 22, 2020 in Python by ashely (50.2k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...