有什么方法可以返回self
已由python中的方法修改过的所有变量吗?
例如,我有一个方法可以修改20个self
变量,并希望self.variable1, self.variable2...
在方法末尾返回。
这是我现在正在做的事情(更大方法的最后一部分):
return (self.p1_error, self.p1,
self.p2_error, self.p2,
self.p3_error, self.p3,
self.p4_error, self.p4,
self.p5_error, self.p5,
self.p6_error, self.p6,
self.p7_error, self.p7,
self.p8_error, self.p8,
self.p9_error, self.p9,
self.p10_error, self.p10)
有没有更简洁的方法?
在方法中维护一个列表,每当更改任何变量时,都将其追加到列表中,并在方法末尾返回列表。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句