how to reduce bugs due to incorrect indentation

Grant Edwards invalid at invalid.invalid
Thu Feb 6 15:49:54 CET 2014


On 2014-02-06, msustik at gmail.com <msustik at gmail.com> wrote:
> I had a bug in a Python script recently. The code in question was something along the lines of:
>
> if a == 1:
>     x = y
> else:
>     x = z
> y = z + y
> z = z + 1
>
> While editing this file I accidentally pushed TAB on the line 
> with 'y = z + y'.
>
> Any suggestion on how to avoid this type of error in the future?

The best advice is to pay closer attention to what you're doing.  Look
at the code while you're editing, not your fingers.  Before you commit
the change, spend some time looking carefully at it to verify that
changes were intentional.

-- 
Grant Edwards               grant.b.edwards        Yow! I left my WALLET in
                                  at               the BATHROOM!!
                              gmail.com            



More information about the Python-list mailing list