Tabs versus Spaces in Source Code ('semantic' vs. arbitrary indentation)

achates aylwyn at cantab.net
Wed May 17 15:25:07 EDT 2006


Andy Sy wrote:

>def sqlcall():
>      cursor.execute('select id, item, amount, field4, field5, field6'+
>                               'from table1 where amount>100')

Lines two and three (a continuation line) are both at a syntactic
indentation level of 1. Therefore they should both start with a tab.
(Though actually indentation is ignored for continuation lines so you
only need to preserve the indentation if you want alignment.)

Then you can add spaces to align the function arguments.

def sqlcall():
<tab>cursor.execute('select id, item, amount, field4, field5, field6'+
<tab><---spaces---->'from table1 where amount>100')

I prefer not to bother with alignment like this, but if you do want to
align things, you use spaces. Indenting is done with tabs; alignment
with spaces.




More information about the Python-list mailing list