Python-3-2
Python-3-2
destructor
print("Destructor called, Example
deleted.")
. obj = Example()
del obj
.
Note : The destructor was called after the program ended or when all the
references to object are deleted i.e when the reference count becomes zero,
not when object went out of scope.
pr__()
on __repr__() function returns the object representation in string format.
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def __repr__(self):
rep = 'Person(' + self.name + ',' + str(self.age) +
')'
return rep