-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdestructor.py
More file actions
37 lines (20 loc) · 913 Bytes
/
destructor.py
File metadata and controls
37 lines (20 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# # # # # # # # # # # # # # # # # # # # # # # # # # DESTRUCTOR # # # # # # # # # # # # # # # # # # # # # # # # # # #
DESTRUCTOR IS A SPECIAL TYPE OF METHOD WHICH IS USED TO DELETE THE OBJECT OF A CLASS
DESTRUCTOR IS CALL WHEN OBJECT GET DESTROYED
DESTRUCTOR IS CALLED ONE FOR ONE OBJECT
DESTUCTOR WILL TAKE 'self' AS A DEFAULT PARAMETER
TO DEFINE A DESTRUCTOR WE USE 'def' KEYWORD
DESTRUCTOR NAME MUST BE '__del__'
THE OBJECT DELETION DONE AUTOMATICALLY IN 'PYCHARM'
WHEREAS IN IDLE WE NEED TO DO MANUALLY USING 'del' KEYWORD
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class Student:
def __init__(self):
print("I am constructor!")
def display(self):
print("I am Display!!")
def __del__(self):
print("I am destructor!!!")
s = Student()
s.display()
del s