1

Previous users have asked whether to put the constructor docstring under the class definition or under __init__. The answer is given in PEP 257 – Docstring Conventions:

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

However, both __new__ and metaclass, as actual constructors, have the ability to modify the function signature before the arguments given to the constructor are passed on to the initializer __init__. Since PEP 257 said the constructor docstring should be written in __init__, should the docstring describe the arguments provided by the user when my_var = MyClass(*args1, **kwargs1) is called, or the arguments when __init__(self, *args2, **kwargs2) is invoked? It is not guaranteed that args1 == args2, kwargs1 == kwargs2. In general, how should the effects of __new__ and metaclass be documented?

Moobie
  • 1,445
  • 14
  • 21

0 Answers0