1

Question about numpydoc docstring conventions:

I have a class that contains a number of methods that return nothing, but add an attribute to the class. For example:

class MyClass(object):
    def __init__(self, a, b):
         self.a = a
         self.b = b
         return

    def a_mult(self, mult):
        """
        Multiplies `a` by `mult`.

        Parameters
        ----------
        mult : float
            Value to multiply `a` by.

        Returns
        -------
        None
        """
        self.product = a * mult
        return

In this clumsy example, MyClass.a_mult doesn't return anything, but adds an attribute to MyClass.

I've included a docstring for MyClass.a_mult following the numpydoc style guide. The docstring states that the method returns None, but I can't see a standard way of documenting how the MyClass.a_mult method modifies the MyClass instance.

Thanks in advance for your help!

4

1 回答 1

-1

遵循@mgilson 和@user2357112 的有用建议,我意识到我的课程设计得很糟糕。我已经改变了数据分析的所有阶段都存储在一个字典中。分析函数现在向字典添加元素,而不是向类实例添加新属性。

感谢您的指点。

于 2016-06-07T00:02:06.837 回答