Constructor documentation assigned to class or __init__?

Holger Türk htx1 at gmx.de
Fri Jun 18 07:04:23 EDT 2004



Leif K-Brooks wrote:
> Should a class's constructor be documented in the class's docstring or 
> __init__'s docstring? For instance:
> 
> class Foo(object):
>     """This class represents mating lizards. Constructor requires one 
> argument, the lizard this lizard is mating with."""
>     def __init__(self, other):
>         pass
> 
> # or
> 
> class Bar(object):
>     ""This class represents mating lizards."""
>     def __init__(self, other):
>         """Initiate the object. Requires one argument, "other", which is 
> the lizard this lizard is mating with."""
>         pass

It's probably a matter of taste, but
I'd prefer the style like in class Bar, because
information about the constructor is technically
nearer to the constructor.
   Please don't write "Initiate the object." That's
what a constructor is (almost) always supposed to do.

Regards,

Holger




More information about the Python-list mailing list