[code.view]

[top] / python / PyMOTW / exceptions / exceptions_ReferenceError.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2008 Doug Hellmann All rights reserved.
     #
     """
     """
     
     __version__ = "$Id$"
     #end_pymotw_header
     
     import gc
     import weakref
     
     class ExpensiveObject(object):
         def __init__(self, name):
             self.name = name
         def __del__(self):
             print '(Deleting %s)' % self
     
     obj = ExpensiveObject('obj')
     p = weakref.proxy(obj)
     
     print 'BEFORE:', p.name
     obj = None
     print 'AFTER:', p.name
     
     

[top] / python / PyMOTW / exceptions / exceptions_ReferenceError.py

contact | logmethods.com