First day beginner to python, add to counter after nested loop

Antoon Pardon antoon.pardon at rece.vub.ac.be
Wed Oct 30 08:42:37 EDT 2013


Op 30-10-13 13:17, Chris Angelico schreef:
> On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon
> <antoon.pardon at rece.vub.ac.be> wrote:
>> Because it is a pain in the ass. Now suddenly my program doesn't work
>> because I somehow inserted a tab instead of spaces.
> 
> I broadly agree with your post (I'm of the school of thought that
> braces are better than indentation for delimiting blocks), but I don't
> think this argument holds water. All you need to do is be consistent
> about tabs OR spaces (and I'd recommend tabs, since they're simpler
> and safer), and you'll never have this trouble.

Easier said than done. First of all I can be as consistent as possible,
I can't just take code from someone else and insert it because that
other person may be consistenly doing it different from me.

Then if you are working on different machines, the settings of your
editor may not always be the same so that you have tabs on one machine
and spaces on an other, which causes problem when you move the code.

Also when you have an xterm, selecting a tab and pasting it into
another it will turn the tab into spaces.

All these things usually can be ignored, they typically only show
up when you print something and things aren't aligned as you expect
but with python you are forced to correct those things immediatly,
forcing you to focus on white space layout issues instead of on
the logic of the code.

> Also, the parser
> should tell you if you mix tabs and spaces, so that won't trip
> anything either.

Maybe you mean something differen than I understand but a program
throwing a syntax error because there is a tab instead of a number
of spaces or vice versa, is something I would understand as tripping.

-- 
Antoon Pardon






More information about the Python-list mailing list