class Employee:
count = 0
def __init__( self, first, last ):
self.firstName = first
self.lastName = last
Employee.count += 1
print "Employee constructor for %s, %s" % ( self.lastName, self.firstName )
def __del__( self ):
Employee.count -= 1
print "Employee destructor for %s, %s" % ( self.lastName, self.firstName )
print "Number of employees before instantiation is", Employee.count
# create two Employee objects
employee1 = Employee( "A", "C" )
employee2 = Employee( "B", "D" )
employee3 = employee1
print "Number of employees after instantiation is", employee1.count
# explicitly delete employee objects by removing references
del employee1
del employee2
del employee3
print "Number of employees after deletion is", Employee.count