verbs in comments [OT]

MRAB python at
Sat Mar 24 21:24:37 CET 2012

On 24/03/2012 19:36, Kiuhnm wrote:
> Why do you write
>     // Print the number of words...
>     def printNumWords(): ...
> and not
>     // Prints the number of words...
>     def printNumWords(): ...
> where "it" is understood?
> Is that an imperative or a base form or something else?
The first is the imperative, the second is what it does (with the
implied "it").

Which form you use depends on what "feels" right.

Probably what I'd do is use the first form where it's called and the
second form where it's defined.

     # Prints the number of words.
     def print_num_words():

     # Print the number of words.

Although in this example the function is better written with a
docstring, and the comment where the function is called doesn't add
anything useful, so it's probably unnecessary.

More information about the Python-list mailing list