DEV Community

Discussion on: 5 common mistakes made by beginner Python programmers

Collapse
 
jbence2001 profile image
Bence Juhász

What's the thing about spaces and tabs? I mean okay I saw it already, that this is a harsh point for programmers, but why? (absolutely newbie here)

Collapse
 
anuragrana profile image
Anurag Rana

Bence,
Python doesn't support mixing tabs and spaces for indentation.

For other languages as well we should stick to one thing, either tab or spaces. This is because of different editors display tabs/spaces differently.

Collapse
 
jbence2001 profile image
Bence Juhász

Thanks for the reply. So I can use tabs or spaces as well but not in the same code, right?

Thread Thread
 
anuragrana profile image
Anurag Rana

Correct.

Collapse
 
cyberspy profile image
Adam

I'm pretty sure that python 2.7 allows mixed tabs and spaces (not that it is recommended) but python 3.x will error if you try that.
PEP 8 recommends spaces, but you can use tabs if that's what a project already uses.
python.org/dev/peps/pep-0008/#tabs...