1self 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.
1class Person:
2 def __init__(mysillyobject, name, age):
3 mysillyobject.name = name
4 mysillyobject.age = age
5
6 def myfunc(abc):
7 print("Hello my name is " + abc.name)
8
9p1 = Person("John", 36)
10p1.myfunc()
11
12#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