2024-06-28 19:01:04 发布
网友
我有时在__init__之外定义一个对象变量。plint和我的IDE(PyCharm)抱怨。在
__init__
plint
class MyClass(): def __init__(self): self.nicevariable = 1 # everyone is happy def amethod(self): self.uglyvariable = 2 # everyone complains
plint输出:
为什么这是不正确的做法?在
Python允许您随时添加和删除属性。在__init__不做有两个问题
Python允许您随时添加和删除属性。在
__init__
不做有两个问题相关问题 更多 >
编程相关推荐