I got the concept of reference count
So when i do a "del astrd" ,reference count drops to zero and astrd gets collected by gc ?
This is the sample codes.These codes I developed after my yesterday's question:link text
one.py:
def abc():
print "Hello"
print "123"
print '345'
two.py:
import one
#reload(one)
#def defg():
one.abc()
three.py:
import os,sys,gc
from time import sleep
import two
#reload(two)
#two.defg()
sleep(20)
directory = os.listdir('.')
for filename in directory:
if filename[-3:] == 'pyc':
print '- ' + filename
print sys.getrefcount(filename)
file_name = os.path.splitext (filename)[0]
del file_name # remove the local reference
del sys.modules[os.path.splitext (filename)[0]] # removes import
gc.collect() # garbage collect
#del sys.modules[filename]
#del filename
#os.remove(filename)
What i did in three.py is correct or not ? Is there any unnecessary step ?If yes,why ?
Please help me out of this.