Try it here
Self in Python

What is self in Python


Self is a keyword in Python used to define an instance or an object of a class.

In Python, it is explicitly used as the first parameter, unlike in Java where it is optional. It helps to differentiate between the methods and attributes of a class from its local variables.

The self variable in the init method refers to the newly created object while in other methods, it refers to the object whose method was called.

The self is a Python keyword which represents a variable that holds the instance of an object. In almost, all the object-oriented languages, it is passed to the methods as a hidden parameter.

Writer profile pic

Prakash on Apr 21, 2020 at 12:04 am

This article is contributed by Prakash. If you like and would like to contribute, you can write your article here or mail your article to . See your article appearing on the main page and help others to learn.

Post Comment

Comments( 0)


Forgot Password

Please enter your email address below and we will send you information to change your password.