原因:
Yes, you should assign all attributes of your object in the
__init__
method.The most important reason to do this is tool support. Many Python IDEs can see the assignments in the
__init__
and use those attributes for type-based autocompletion. Sphinx-doc can list those attributes in your reference documentation.
来源:
两个讨论:
例子:
Tesorflow project in Githup
时间: 2024-10-19 18:07:50