We're starting with the Explosion
classes because they don't create instances of any other classes. A depth-up kind of strategy is as good as any for this kind of testing.
ExplosionClasses_00.py
file from the Chapter12
folder. Pop
class:def __del__(self): print("Pop Removed")
Boom
class:def __del__(self): print("Boom Removed")
Pops
and Booms
vanish. Sequence
to call our destroy
method after a set amount of time, but we aren't starting that Sequence
so our destroy
method is never called! Add this line of code to the bottom of the __init__
method for both classes:self.seq.start()
Sequence
is constructed with a Func Interval
, and we give one of our class methods to that Func Interval
. That means the Sequence
is storing a reference to the method in the Func Interval
, and that reference is enough to keep the class instance alive. Add this line to both destroy
methods, right above the line that says self.self = None:
self.seq = None
ExplosionClasses_01.py
. Open GunClasses_00.py
and update its import to use ExplosionClasses_01.py
, and then resave it with the same name. Pops
and Booms
have been removed from memory. __del__
methods from the classes and resave the file as ExplosionClasses_02.py
.