Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

meaning of self keyword in user defined function


class food():
 
# init method or constructor
def __init__(self, fruit, color):
self.fruit = fruit
self.color = color
 
def show(self):
print("fruit is", self.fruit)
print("color is", self.color )
 
apple = food("apple", "red")
grapes = food("grapes", "green")
 
apple.show()
grapes.show()
Source by www.edureka.co #
 
PREVIOUS NEXT
Tagged: #meaning #keyword #user #defined #function
ADD COMMENT
Topic
Name
4+2 =