if - else

John J. Lee jjl at pobox.com
Thu Nov 27 12:57:00 EST 2003


Duncan Booth <duncan at NOSPAMrcp.co.uk> writes:

> Jeff Wagner <JWagner at hotmail.com> wrote in
> news:oanasvs703tipmup24qgc5toggte8uh67n at 4ax.com: 
[...]
> >         if SumOfNumbers = 10:
> >             #If SumOfNumbers = 10, then set it's value to 1
> >             SumOfNumbers = 1
[...]

Classic example of a worse-than-useless comment: it just repeats the
code (even experienced programmers frequently fall into this trap,
though they're not usually quite so blatant about it ;-).  The idea is
to explain why you're doing something, not just to restate it (which
creates maintenance work and can positively mislead people if it's out
of sync with the code).  Think about the code you're *not* commenting:
it's usually the context that's not clear to readers, not the detailed
logic of the commented code.


John




More information about the Python-list mailing list