On 17/09/2007, Ara Kooser <[EMAIL PROTECTED]> wrote: > Give certain conditions I want the yeast cell to die. Kent suggested I > use something this: > yeasts = [yeast for yeast in yeasts if yeast.isAlive()] to clear out > dead yeast. [...] > class Yeast: [...] > def isAlive(self): > if self.life > 0: > self.alive = True > else: > self.alive = False
Most programmers would see an 'isAlive' method as a method that would return True if the thing is alive, and False otherwise. So you would define it as: def isAlive(self): if self.life > 0: return True else: return False Then you could write code like this: # suppose 'y' is a yeast object # If y is alive, make it grow. if y.isAlive(): y.grow() (actually, you can write this method much more concisely: def isAlive(self): return self.life > 0 ) HTH! -- John. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor