0

从类创建实例对象后,您可以使用对象的init方法将其变量设置为新的吗?

前任:

class Object1(Object):

    def __init__(self, name, ability):
        self.name = name
        self.ability = ability

example1 = Object1("example", "none")
#new object created with parameters set by the __init__ method 

example1.__init__("changeExample", "Changed")
#called the __init__ method on the object and changed the parameters.   Is this okay to do?
4

0 回答 0