Search
 
SCRIPT & CODE EXAMPLE
 

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()
Comment

PREVIOUS NEXT
Code Example
Python :: How to add an item from another set or other data structures (lists, dictionaries, and tuples) to a set by using the update() method. 
Python :: check if a PID exists on a UNIX based system 
Python :: How determine if a number is even or odd using Recursive Inner Function 
Python :: split dataset folders in train test valid using python 
Python :: python os path join list 
Python :: reverse bolean python 
Python :: how to check columns with the numerical values 
Python :: Python Tkinter Message Widget Syntax 
Python :: python module equal override 
Python :: Comparing Sets with issubset() Function in python 
Python :: box plot seaborn advance python 
Python :: saving to PIL image to s3 
Python :: python - Creating Tkinter buttons to stop/skip a 2D loop [Solved 
Python :: python yield async awiat 
Python :: handling files in django 
Python :: pandas merge keep one of column copy 
Python :: Call a function after every x seconds 
Python :: python script to open google chrome 
Python :: pandas concatenation (concat) using list comprehension 
Python :: how to detect if a key was press down 
Python :: Using iterable unpacking operator * with extend 
Python :: list of ones python 
Python :: _rocketcore pypi 
Python :: 56.5 to 57 in python 
Python :: readline python sin avanzar de linea 
Python :: gym for creating simple grid world 
Python :: jhon wick 
Python :: django composer 
Python :: Python Write to File Way01 
Python :: Python Raw String to ignore escape sequence 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =