gpt4 book ai didi

python - 记录抽象基类的属性?

转载 作者:行者123 更新时间:2023-12-03 21:20:11 24 4
gpt4 key购买 nike

我有一个抽象基类,并且每个后代都应该具有某些属性(类型为 str、int 等),因此在基类中记录这些属性是有意义的。在 Python 3.6+ 中记录这些属性的推荐格式是什么?

最佳答案

最好的来源可能是 PEP 257,特别是关于子类化的指南。

来自 PEP 257

The docstring for a class should summarize its behavior and list the public methods and instance variables. If the class is intended to be subclassed, and has an additional interface for subclasses, this interface should be listed separately (in the docstring). The class constructor should be documented in the docstring for its init method. Individual methods should be documented by their own docstring.

关于python - 记录抽象基类的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52031012/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com