delete object python code example
Example 1: python delete object
class Thing(object):
def __del__(self):
print("Object was deleted.")
def func(self):
print("Random function ran from class Thing().")
random_object = Thing()
random_object.func()
del random_object
random_object.func()
Example 2: deleting an object in python
>>> class Test:
... def __del__(self):
... print "deleted"
...
>>> test = Test()
>>> del test
deleted
Example 3: python delete class object
del <whatever object name you want to delete>