# -*- coding: utf-8 -*-
class Student(object):
count = 0
# count += 1
def __init__(self, name):
self.name = name
Student.count += 1
def __del__(self):
Student.count -= 1
print(Student.count == 0)
bart = Student('Bart')
print(Student.count == 1)
auther = Student('Auther')
print(Student.count == 2)
del auther
Sign in to make a reply
岁益寒
# -*- coding: utf-8 -*-
class Student(object):
count = 0
# count += 1
def __init__(self, name):
self.name = name
Student.count += 1
def __del__(self):
Student.count -= 1
print(Student.count == 0)
bart = Student('Bart')
print(Student.count == 1)
auther = Student('Auther')
print(Student.count == 2)
del auther
print(Student.count == 1)