The 'while' doesn't 'break' when self.text is set to '' by the kill function.
Can someone help me make this work or suggest a better way? Need to run a string through 10+ functions quitting if string becomes '' Returning inside each function seems redundant.
class Class(object):
def run(self, text):
self.text = text
while self.text:
self.nothing1()
self.kill()
self.nothing2()
return self.text # stop if all functions run
def nothing1(self):
print 'nothing1'
self.text = self.text
def kill(self):
print 'kill'
self.text = ''
def nothing2(self):
print 'nothing2'
self.text = self.text
C = Class()
C.run('some string')
Clarification: Goal is to run a string through a many functions in order just once stopping if any one of the functions sets the string to "", i obviously misunderstand how 'while' work, it seems the cleanest way to me.
kill? There is not break statement. So it executes the rest of the functions bellowkill. But the next iteration ofwhiledoesn't go because the conditionself.nect==Trueis not met.