osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python indentation (3 spaces)


05.10.18 23:53, Chris Angelico ????:
> I don't understand how three spaces would prevent errors in a way that
> four wouldn't.
In many editors and on terminal

for a in x:
     if a:
         b()
<-tab-->c()

looks indistinguishable from

for a in x:
     if a:
         b()
         c()

but the former is a syntax error in Python 3.

If use 3-space indentation this error is more visible:

for a in x:
    if a:
       b()
<-tab-->c()