First of all, let me correct you - self is not a method. Moving further:

Technically both self and this are used for the same thing. They are used to access the variable associated with the current instance. Only difference is, you have to include self explicitly as first parameter to an instance method in Python, whereas this is not the case with Java. Moreover, the name self can be anything. It's not a keyword, as you already know. you can even change it to this, and it will work fine. But people like to use self, as it has now become a bit of a convention.

Here's a simple instance method accessing an instance variable in both Python and Java:

Python:

class Circle(object):
    def __init__(self, radius):
        # declare and initialize an instance variable
        self.radius = radius

# Create object. Notice how you are passing only a single argument.  
# The object reference is implicitly bound to `self` parameter of `__init__` method
circle1 = Circle(5);

Java:

class Circle {
    private int radius;

    public Circle(int radius) {
        this.radius = radius;
    }
}

Circle circle1 = new Circle(5);

See also:

  • Wiki page of this
Answer from Rohit Jain on Stack Overflow
🌐
W3Schools
w3schools.com β€Ί python β€Ί python_ref_keywords.asp
Python Keywords
Python Examples Python Compiler ... ... Python has a set of keywords that are reserved words that cannot be used as variable names, function names, or any other identifiers:...
Top answer
1 of 4
138

First of all, let me correct you - self is not a method. Moving further:

Technically both self and this are used for the same thing. They are used to access the variable associated with the current instance. Only difference is, you have to include self explicitly as first parameter to an instance method in Python, whereas this is not the case with Java. Moreover, the name self can be anything. It's not a keyword, as you already know. you can even change it to this, and it will work fine. But people like to use self, as it has now become a bit of a convention.

Here's a simple instance method accessing an instance variable in both Python and Java:

Python:

class Circle(object):
    def __init__(self, radius):
        # declare and initialize an instance variable
        self.radius = radius

# Create object. Notice how you are passing only a single argument.  
# The object reference is implicitly bound to `self` parameter of `__init__` method
circle1 = Circle(5);

Java:

class Circle {
    private int radius;

    public Circle(int radius) {
        this.radius = radius;
    }
}

Circle circle1 = new Circle(5);

See also:

  • Wiki page of this
2 of 4
45

About self in Python (here is the source: Python self explanation):

The reason you need to use self. is because Python does not use the @ syntax to refer to instance attributes. Python decided to do methods in a way that makes the instance to which the method belongs be passed automatically, but not received automatically: the first parameter of methods is the instance the method is called on. That makes methods entirely the same as functions, and leaves the actual name to use up to you (although self is the convention, and people will generally frown at you when you use something else.) self is not special to the code, it's just another object.

Python could have done something else to distinguish normal names from attributes -- special syntax like Ruby has, or requiring declarations like C++ and Java do, or perhaps something yet more different -- but it didn't. Python's all for making things explicit, making it obvious what's what, and although it doesn't do it entirely everywhere, it does do it for instance attributes. That's why assigning to an instance attribute needs to know what instance to assign to, and that's why it needs self..

About this in Java being explained by Oracle (here is the source: Java this explanation):

Within an instance method or a constructor, this is a reference to the current object β€” the object whose method or constructor is being called. You can refer to any member of the current object from within an instance method or a constructor by using this. The most common reason for using the this keyword is because a field is shadowed by a method or constructor parameter.

🌐
Real Python
realpython.com β€Ί python-keywords
Python Keywords: An Introduction – Real Python
February 12, 2025 - Python keywords are the fundamental building blocks of any Python program. In this tutorial, you'll learn the basic syntax and usage of each of Python's thirty-five keywords and four soft keywords so you can write more efficient and readable code.
🌐
Wikipedia
en.wikipedia.org β€Ί wiki β€Ί This_(computer_programming)
this (computer programming) - Wikipedia
November 7, 2025 - Also starting with PowerShell 5.0, which adds a formal syntax to define classes and other user-defined types, $this variable describes the current instance of the object. In Python, there is no keyword for this.
🌐
Programiz
programiz.com β€Ί python-programming β€Ί keyword-list
List of Keywords in Python Programming
Here, we have created an inline function that doubles the value, using the lambda statement. We used this to double the values in a list containing 1 to 5. Learn more about Python lamda function. The use of nonlocal keyword is very much similar to the global keyword.
🌐
Quora
quora.com β€Ί What-is-the-difference-between-self-this-and-me-in-Python
What is the difference between self, this, and me in Python? - Quora
Answer: Python methods require a first parameter referring to the instance the method was called on whose name is completely up to you! By convention β€˜self’ is used, but you may call it whatever you want. Note that a method call does not need that first argument!
🌐
Python
docs.python.org β€Ί 3 β€Ί library β€Ί keyword.html
keyword β€” Testing for Python keywords
This module allows a Python program to determine if a string is a keyword or soft keyword. ... Return True if s is a Python keyword. ... Sequence containing all the keywords defined for the interpreter.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί python-keywords
Python Keywords - GeeksforGeeks
January 5, 2017 - In Python, the keyword global is used to indicate that a variable is global. This keyword is used inside a function to refer to a variable that is defined in the global scope, allowing the function to modify the global variable directly.
Find elsewhere
🌐
W3Schools
w3schools.com β€Ί python β€Ί ref_keyword_in.asp
Python in Keyword
Python Examples Python Compiler ... Bootcamp Python Certificate Python Training ... The in keyword is used to check if a value is present in a sequence (list, range, string etc.)....
🌐
Python.org
discuss.python.org β€Ί ideas
Adding of a new keyword: when - Ideas - Discussions on Python.org
October 17, 2023 - I hereby propose the keyword when This keyword has appeared to me as a good feature to simplify the process of creating and handling events in python. It would be much easier for newcomers to create a program with event using this keyword. The when keyword create a thread that observe the variables in the condition.
🌐
EyeHunts
tutorial.eyehunts.com β€Ί home β€Ί python this keyword
Python this keyword
December 9, 2022 - this, self, and Me are keywords used in computer programming languages to refer to the object, class, or other entity of which the currently running code is a part. Simple example code. class food(): # init method or constructor def __init__(self, ...
🌐
Programiz
programiz.com β€Ί python-programming β€Ί keywords-identifier
Python Keywords and Identifiers (With Examples)
In this tutorial, you will learn about keywords (reserved words in Python) and identifiers (names given to variables, functions, etc). Keywords are the reserved words in Python. We cannot use a keyword as a variable name, function name or any other identifier.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί keywords-python-set-2
Keywords in Python | Set 2 - GeeksforGeeks
April 21, 2025 - 30. in : This keyword is used to check if a container contains a value. This keyword is also used to loop through the container. 31. is : This keyword is used to test object identity, i.e to check if both the objects take same memory location or not.
🌐
Javatpoint
javatpoint.com β€Ί python-keywords
Python keywords - javatpoint
python keywords - A simple and easy to learn tutorial on various python topics such as loops, strings, lists, dictionary, tuples, date, time, files, functions, modules, methods and exceptions.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί python-keywords-and-identifiers
Python Keywords and Identifiers - GeeksforGeeks
August 19, 2025 - We can also get all the keyword names using the below code. ... ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is',... User-defined names for variables, functions, classes, modules, etc. Can include letters, digits, and underscores (_). Case-sensitive β†’ num, Num, and NUM are different identifiers. Python provides str.isidentifier() to check if a string is a valid identifier.
🌐
Testbook
testbook.com β€Ί home β€Ί python β€Ί python keywords and identifiers
List Of Python Keywords And Identifiers With Suitable Examples
18 Months Testbook Pass
There are 33 keywords in Python like def, pass, etc. They can’t be used as identifiers. Learn more about keywords & identifiers in Python in this tutorial. Attempt all tests for all your exams using our 18 Months Testbook Pass
Rating: 4.6 ​
🌐
WsCube Tech
wscubetech.com β€Ί resources β€Ί python β€Ί keywords
Keywords in Python: All Lists With Examples
October 1, 2025 - Explore all Python keywords in our comprehensive list with examples. Learn how to use each keyword effectively in your Python programming.
Top answer
1 of 4
126

There is no less verbose way. Always use self.x to access the instance attribute x. Note that unlike this in C++, self is not a keyword, though. You could give the first parameter of your method any name you want, but you are strongly advised to stick to the convention of calling it self.

2 of 4
55

I'll supplement Sven's (accurate) response with an answer to the natural follow-up question (i.e. Why is self explicit rather than implicit?).

Python works this way as it operates on the idea of lexical scoping: bare name references will always refer to a local variable within the current function definition, a local variable of a containing function definition, a global variable of the module, or a builtin. (The scoping is lexical as when you follow the parse tree down during symbol analysis, you only need to remember the names seen in the function definitions on the path down to the current function - anything else can be handled as "not seen, therefore global or builtin". It's also worth explicitly noting that the scoping rules relate to nesting of function definitions rather than calls).

Methods are not given any particular special treatment in that regard - class statements are largely irrelevant to the lexical scoping rules, since there isn't the same sharp function vs method distinction that exists in some languages (Instead, methods are dynamically created from functions when the relevant attributes are retrieved from objects).

This allows a function to be added to a class after it has already been defined and be indistinguishable from those methods that were defined within the body of the class statement (a process known as "monkeypatching").

Since object namespaces are separate from the lexical scoping rules, it is necessary to provide some other way to reference those attributes. This is the task handled by the explicit self.

Note that for complex algorithms, it is not uncommon to cache references to member variables as local variables within the method.

🌐
ScholarHat
scholarhat.com β€Ί home
List of Python Keywords (With Examples)
September 10, 2025 - Python Keywords are one of the very beginner concepts of the Python language that you need to know for basic Python programs. Keywords are reserved words that convey a special meaning and purpose within the context of the language. In this Python Tutorial, you will get to know What are Keywords in Python with examples and types of Keywords in Python and How to identify Python Keywords and their usage.
🌐
AskPython
askpython.com β€Ί home β€Ί python keywords
Python Keywords - AskPython
July 5, 2022 - Python keywords are the reserved words. There are 35 keywords in Python 3.10.5. Python interpreter uses keywords to understand the program and execute it.