2024-09-14 18:01:34 发布
网友
在记录实例变量时,我可以
class Foo: def __init__(self): self.spam = 4 """Docstring for instance attribute spam."""
这不适用于平行作业
如何记录并行分配中的变量?在
^{}用于单个属性。下面是一种与autoclass或automodule一起使用的方法:
autoclass
automodule
class Foo: """ :ivar spam: Description of spam :ivar bar: Description of bar :ivar moo: Description of moo """ def __init__(self): self.spam, self.bar, self.moo = 4, 5, 6
与使用autoattribute得到的结果相比,输出看起来有点不同,但我非常喜欢它。在
autoattribute
我发现我可以在__init__doc string块中使用Sephix标记,使其看起来与使用autoattribute几乎相同。在
__init__
class Foo: def __init__(self): """ Something something .. py:attribute:: spam Something about spam .. py:attribute:: bar Something about br .. py:attribute:: moo Something about moo """ self.spam, self.bar, self.moo = 4, 5, 6
这看起来像 http://xrxr.github.io/RapidPygame/levelmgr.html (使用此技术完成解释和绘制清单。) 如果autoclass_content设置为'both' (如果你注意了,它们不是按字母顺序排列的)
autoclass_content
'both'
这行得通,但我还是想知道有没有更好的办法。在
^{} 用于单个属性。下面是一种与
autoclass
或automodule
一起使用的方法:与使用
autoattribute
得到的结果相比,输出看起来有点不同,但我非常喜欢它。在我发现我可以在
__init__
doc string块中使用Sephix标记,使其看起来与使用autoattribute几乎相同。在这看起来像 http://xrxr.github.io/RapidPygame/levelmgr.html (使用此技术完成解释和绘制清单。) 如果
autoclass_content
设置为'both'
(如果你注意了,它们不是按字母顺序排列的)这行得通,但我还是想知道有没有更好的办法。在
相关问题 更多 >
编程相关推荐