On Thursday, February 6, 2014 5:02:09 AM UTC+2, msu...@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'. > 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? > Thanks!
I see. The only solution to mimic C style curly brackets comes to my mind is to use hash to mark start and stop of your block as: if a == 1:# x = y # else:# x = z # y = z + y z = z + 1 and PEP ... Nulla poena sine lege :-) /Asaf -- https://mail.python.org/mailman/listinfo/python-list