为什么我需要
class DummyObject(object):
pass
为了制作
dummy = DummyObject()
dummy.foo = 42
为什么这在Python中不合法?
dummy = object()
dummy.foo = 42
出现错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'object' object has no attribute 'foo'