Karl Kobata wrote:
Please post code that works. Use cut and paste.
Have you read the manual section on the del statement?
Most programs use del rather sparingly. Most temporary objects are
created within functions and get unbound automatically when the function
exits. If you need to guarantee release of external resources before
the program ends, make explict calls to .close methods of the instances
that connect to them. Actually memory recovery depends on the
implementation and version. I would not worry about this until you
really need to.
Objects will not be destroyed while still reachable from code (in the
absence of a severe bug).
Don't indent main body code.
Do use legal keywords.
tjr
Please help. Questions based on snippet of code below.
1) when myTestCase is deleted, is just the pointer deleted or the
entire instance with all of its data and data structure deleted?
entire instance with all of its data and data structure deleted?
2) What is the practice for deleted the object and recovering the
memory it occupies?
memory it occupies?
created within functions and get unbound automatically when the function
exits. If you need to guarantee release of external resources before
the program ends, make explict calls to .close methods of the instances
that connect to them. Actually memory recovery depends on the
implementation and version. I would not worry about this until you
really need to.
3) If delete is the way, what happens to
‘testUtils.util Function1()’ if it were instantiated in other classes
that have not been deleted yet?
‘testUtils.util Function1()’ if it were instantiated in other classes
that have not been deleted yet?
absence of a severe bug).
import testUtils
class testClass:
def __init__(self):
self.testList = list()
self.testDict1 = dict()
self.utils1 = testUtils.utilF unction1()
class testClass:
def __init__(self):
self.testList = list()
self.testDict1 = dict()
self.utils1 = testUtils.utilF unction1()
myTestCase = testClass()
delete myTestCase
delete myTestCase
Do use legal keywords.
tjr