Question regarding commenting code

Werner Schiendl ws-news at gmx.at
Thu Sep 6 13:59:14 EDT 2001


Hi,

in addition, I would recommend to comment a whole block of code instead of
every single line.
This makes it easier, to comment what is done instead of how it is done. The
latter can usually easily be done by just reading the code.
Moreover, your code becomes quickly hard to read if every other line is a
comment.

so instead of

> for n in a_list:
>     # separate values using spaces as delimiters
>     a_line = string.split(n)
>     # get the first value
>     a_value = a_line[0]
>     # print the first value
>     print a_value

maybe something like

> # separate values of all items in a_list using spaces as delimiters,
> # get the first value and print it
> for n in a_list:
>     a_line = string.split(n)
>     a_value = a_line[0]
>     print a_value

Even better would be an (additional) hint on what this could should do in
context of the program.
But this cannot be derived from your snippet.

just my 2 cent
Werner






More information about the Python-list mailing list