最后三行有什么问题?
class FooClass(object):
pass
bar1 = object()
bar2 = object()
bar3 = object()
foo1 = FooClass()
foo2 = FooClass()
foo3 = FooClass()
object.__setattr__(foo1,'attribute','Hi')
foo2.__setattr__('attribute','Hi')
foo3.attribute = 'Hi'
object.__setattr__(bar1,'attribute','Hi')
bar2.attribute = 'Hi'
bar3.attribute = 'Hi'
我需要一个具有单个属性(如 foo)的对象,我应该为它定义一个类(如 FooClass)吗?