Class destructor: __del__ : Class del « Class « Python






Class destructor: __del__

Class destructor: __del__

class Life:
     def __init__(self, name='unknown'):
         print 'Hello', name
         self.name = name
     def __del__(self):
         print 'Goodbye', self.name

brian = Life('Brian')

brian = 'loretta'

print "Before delete"

print brian

del brian

print "after delete"


           
       








Related examples in the same category