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 objectsemployee1 = Employee( "A", "C" )employee2 = Employee( "B", "D" )employee3 = employee1print "Number of employees after instantiation is", employee1.count# explicitly delete employee objects by removing referencesdel employee1del employee2del employee3print "Number of employees after deletion is", Employee.count
Name (required)
email (will not be published) (required)
Website