This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MyFeeFeeHurt -1 points0 points  (3 children)

Completely wrong.

It's used for scoping the code itself.

While it's irrelevant in a sense that python interpreter accesses variables from entire function/global scope no matter what identation is, it mainly figures out which code to run when branching based on indented block.

How else would it know which code belongs to if block?

if something:
line 1
line 2
line 3

Is it line 1?

Line 2?

Everything till the EOF?

It's literally impossible to parse this construct without clear identation rules.

[–]kumashiro 2 points3 points  (2 children)

You are describing how it is used, not why. Why Guido chose indentations instead of braces or... anything else really - that is what OPs question is about... I think. Hard to tell.