Ara Kooser wrote:
> I have two instances called and running. They interact with each
> other and I would like one of the instances to cease to exist in the
> second round based on a given condition. How do you kill an instance?
What you really need is for your main code to stop using the instance.
You could write it like this:
if one.isAlive():
one.lys_re("lys")
if two.isAlive():
two.ade_re("ade")
etc.
But your two classes are so similar, I would try to merge them into one
class and have the behaviour (which aa they consume or release)
determined by configuration. Then you can keep the instances in a list
and treat them uniformly. Something like
yeasts = [Yeast("Red","alpha", "lys", "ade"), Yeast("Yellow","alpha",
"ade", "lys")]
#Game logic
while count < rounds:
for yeast in yeasts:
yeast.release()
print
print "Chemicals in the environment",chemicals
print
time.sleep(1)
for yeast in yeasts:
yeast.consume()
# This step removes dead yeasts from the list
yeasts = [yeast for yeast in yeasts if yeast.isAlive()]
> def ade_need(self,stuffb):
>
> if stuffb != chemicals:
I'm not sure what you think you are testing, but this will always be
true; stuffb is a string and chemicals is a list, they will never be
equal. I think you want
if stuffb in chemicals:
Kent
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor