class Player:
"Defining Class"
#private variable
__test_variable = 100
# __init__ method acts as constructor for class
# this method initialises class variable values to values passed while creating object
def __init__(self, name, team):
self.name = name
self.team = team
def __del__(self):
class_name = self.__class__.__name__
print("Destroyed :",class_name," with id :",id(self)) # Here id() method shows unique identification number of object in Python
#private method
def __displayPlayer(self):
print("Player",self.name,"says hi from",self.team)
#public method
def listPlayerMsg(self):
self.__displayPlayer()
#Following statement creates object
p1 = Player("Prayag", "India")
#Accessing object variables and functions
print(p1.name)
print(p1.team)
#List players, this method is public method so can be accessed.
p1.listPlayerMsg()
#Deleting Objects in Python
del p1