Put dockers on special methods?

I am trying to decide what information to put in the docstring class and what to add to the __init__ docstring method. Until now, I talked about the class and how to work with it in the docstring class, while the material directly related to initialization (argument details, etc.) I put in __init__ docstring.

Today I started wondering if this is the right way to do this, so I looked at a couple of built-in modules and I see that the __init__ method almost never has a docstring. According to PEP8, "Docstrings are not needed for non-public methods", but not __init__ public?

In the same vein, what about other special methods like __getitem__ , __getattr__ or __new__ , should they have docstrings? Or should I just mention the implications they have in the docstring class?

+6
python docstring
source share
1 answer

Straight from PEP 257 :

General methods (including the __init__ constructor) must also have docstrings.

[...]

The constructor of the class must be documented in docstring for its __init__ method.

+9
source share

All Articles