destroy class python code example
Example 1: python class destructors
class animal:
def __init__(self,name):
self.name = name
print(name+" has been born!")
def __del__(self)
print(self.name+" has died D:")
ben = animal("Ben")
del ben
Example 2: python delete class object
del <whatever object name you want to delete>
Example 3: python class destroying
class animal:
def __init__(self,name):
self.Name = name
def __del__(self):
print(self.Name+" has died D:")
ben = animal("Ben")
def deleteObj(obj):
del obj
deleteObj(ben)