Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

self keyword in python

class Person:
  def __init__(mysillyobject, name, age):
    mysillyobject.name = name
    mysillyobject.age = age

  def myfunc(abc):
    print("Hello my name is " + abc.name)

p1 = Person("John", 36)
p1.myfunc()

#self represents the instance of the class. By using the “self” keyword we can access the attributes and methods of the class in python. It binds the attributes with the given arguments. The reason you need to use self. is because Python does not use the @ syntax to refer to instance attributes
Comment

self keyword in python

self keyword
Comment

PREVIOUS NEXT
Code Example
Python :: pyinstaller 
Python :: python split string regular expression 
Python :: default argument in flask route 
Python :: indices of true boolean array pyton 
Python :: pandas how to start read csv at a certain row 
Python :: python numpy arrays equality 
Python :: create a new file in python 3 
Python :: how to check if mouse is over a rect in pygame 
Python :: how to remove numbers from string in python dataframe 
Python :: Setting a conditional variable in python. Using an if else statement in python. 
Python :: The following code shows how to reset the index of the DataFrame and drop the old index completely: 
Python :: opencv skip video frames 
Python :: python change a key in a dictionary 
Python :: python read column data from text file 
Python :: spyder 3.3.6 requires pyqtwebengine<5.13; python_version = "3", which is not installed. 
Python :: install python selenium webdriver 
Python :: check python version conda env 
Python :: what is a cube minus b cube 
Python :: find rows in dataframe from another dataframe python 
Python :: how to upload file in python tkinter 
Python :: Tkinter button icons 
Python :: pip install specific version 
Python :: Network.py socket 
Python :: tkinter window background color 
Python :: filter dataframe 
Python :: pyAudioAnalysis 
Python :: check if float is integer python 
Python :: how to redirect in flask to the same page 
Python :: adjust size of plot 
Python :: django model current timestamp 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =