msus...@gmail.com schreef:
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'.

My changes were elsewhere and I did not notice the above one line change when I 
looked at the diffs before commit. I should have noticed it...

It was rare that a was 1 and therefore the problem did not show up for a while. 
(I know I should have had tests exercising all cases...)

When the bug showed up, it was kind of difficult to remember what was the 
original intent. Fortunately, looking at old versions allowed me to find the 
problem commit and the bug.

Any suggestion on how to avoid this type of error in the future?

My suggestion: configure your editor to insert the appropriate amount of spaces instead of a tab when you press the tab key.


Best regards,
Roel

--
"Met een spitsvondig citaat bewijs je niets."
        -- Voltaire

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to