Scope questions

Dale Strickland-Clark dale at out-think.NOSPAM.co.uk
Thu Jul 20 18:45:33 EDT 2000


Could someone help me out with some scope and instantiation questions?

In moduleA we have:

varB = 1
class classC:
    varD = 1
    def __init__(self):
        self.varE = 1

As I understand it, varB appears when the module is imported and stays
around until the end of the program.

When does varD appear?
How long does it exist?

In the main code I use the above module and have:

import moduleA
varJ = moduleA.classC
varK = varJ.varE
varJ = None

Again, as I understand it, varK contains a reference to varE in class
instance varJ. What happens to varK when the instance reference in varJ goes
away? Does the instance get deleted or is there still a reference to it?

Thanks for any help.

Dale Strickland-Clark






More information about the Python-list mailing list