Skip to content

Commit

Permalink
Destructor method.
Browse files Browse the repository at this point in the history
__del__(self):
print('destroyed')
  • Loading branch information
m-kashani committed Jul 9, 2018
1 parent f3b0d9a commit f533b5a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Object-Oriented-Programming/MohammadrezaKasaieSharifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def __init__(self, name):

def thisFunctionName(self, name):
print(name)

def __del__(self):
print(self.name,' destroyed')

if __name__ == '__main__': # Module besurate dasti ejra shode.

Expand Down Expand Up @@ -52,4 +55,4 @@ def thisFunctionName(self, name):
# del(a)
# We do not have the arrow from a to 1 any more.
# If I say del(b) there is no a and b.
# Now python will figure out that we have an object with no use!
# Now python will figure out that we have an object with no use!

0 comments on commit f533b5a

Please sign in to comment.