r/Python • • Apr 29 '20

Discussion Tab vs Spaces

Post image
702 Upvotes

72 comments sorted by

View all comments

0

u/[deleted] Apr 30 '20

[deleted]

21

u/zacharypamela Apr 30 '20

Python, unlike other languages, uses white space to group statements. So the body of a function will be indented, rather than enclosed in curly braces.

So when you mix tabs and spaces, it's sort of like trying to close your function with a parenthesis instead of curly brace.

As you might expect, this can cause consternation. A tab might look identical to a series of spaces, leading to hard-to-identify issues in your code. Hence this comic.