I have situation where (pseudo code):
class MyClass:
def __init___(self):
self.varA = [zza, b, c]
self.varB = [d, e, zzf]
def process(self):
self.varA = ["zz" + w for w in self.varA if "zz" not in self.varA]
self.varB = ["zz" + w for w in self.varB if "zz" not in self.varB]
print varA, varB
What I would like to have is something more elegant, where I could pass variable to process through definition:
class MyClass:
def __init___(self):
self.varA = [zza, b, c]
self.varB = [d, e, zzf]
def addZZ(list):
return list = ["zz" + w for w in list if "zz" not in list]
def process(self):
self.addZZ(varA)
self.addZZ(varB)
print self.varA, self.varB
But that would mean it has to dynamically change attribute within that def ? How can I approach it ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…