>>> class Test(object): pass
>>> t = Test()
>>> type(t) is t.__class__
True
>>> type(t)
__main__.Test

So those two are the same. I would use self.__class__ since it's more obvious what it is.

However, type(t) won't work for old-style classes since the type of an instance of an old-style class is instance while the type of a new-style class instance is its class:

>>> class Test(): pass
>>> t = Test()
>>> type(t) is t.__class__
False
>>> type(t)
instance
Answer from ThiefMaster on Stack Overflow
🌐
Python
peps.python.org › pep-0673
PEP 673 – Self Type - Python Enhancement Proposals
November 10, 2021 - This PEP introduces a simple and intuitive way to annotate methods that return an instance of their class. This behaves the same as the TypeVar-based approach specified in PEP 484 but is more concise and easier to follow.
🌐
Real Python
realpython.com › python-type-self
Python's Self Type: How to Annotate Methods That Return self – Real Python
July 3, 2026 - Due to its intuitive and concise syntax, as defined by PEP 673, the Self type is the preferred annotation for methods that return an instance of their class. The Self type can be imported directly from Python’s typing module in version 3.11 and beyond.
Discussions

Python: self.__class__ vs. type(self) - Stack Overflow
I'm wondering if there is a difference between class Test(object): def __init__(self): print self.__class__.__name__ and class Test(object): def __init__(self): print type... More on stackoverflow.com
🌐 stackoverflow.com
Using `Self` with classmethod and a `Self` class attribute - Typing - Discussions on Python.org
Hello, I’m trying to type the following code, where a class has a class attribute containing a reference to itself (something like a Singleton for instance). It would look like this: from typing import Self class MyClass: _singleton: Self | None = None @classmethod def new(cls) -> Self: if ... More on discuss.python.org
🌐 discuss.python.org
0
June 16, 2024
PEP 673 -- Self Type
As someone who appreciates static type checking and occasionally likes adding alternate "constructors" to classes using classmethod, this is super convenient! No need to define a TypeVar with a bound for correctness: from typing import Self class Shape: @classmethod def from_config(cls, config: dict[str, float]) -> Self: return cls(config["scale"]) It's also nice that this would sorta be a "canonical" typing for self in instance methods once accepted. More on reddit.com
🌐 r/Python
39
191
November 11, 2021
The Self type in Python 3.11
I understand that it's whole purpose is to avoid typing class name as a string (e.g. "Shape") According to the PEP , the main motivation is to avoid errors caused by too-specific return types on methods that return self. It's about having a an easier and more straight forward solution than manually defining a TypeVar and specifying the type of self, not about avoiding typing two " characters. but use Self type directly (which is a local alias to Shape). It's not equivalent to the name of the class. It's equivalent to a TypeVar bounded by the class. Shall I annotate each self parameter of each class method with Self? self parameters of instance methods will already have the type Self if you use Self anywhere in the signature - and if you don't there's no point in using it as the type of self. You do not need to annotate it. Class methods should not have a parameter named self. Conventionally, their first parameter should be named cls and its type is not going to be Self, it's going to be Type[Self]. And again, you don't need to annotate that. More on reddit.com
🌐 r/learnpython
6
5
April 22, 2025
🌐
GeeksforGeeks
geeksforgeeks.org › python › self-type-in-python
Self Type in Python - GeeksforGeeks
July 23, 2025 - Self-type is a brand-new function added to Python 3.11. A method or function that returns an instance of the class it belongs to is defined by the self type.
🌐
Python documentation
docs.python.org › 3 › library › typing.html
typing — Support for type hints
1 week ago - Special type to represent the current enclosed class. ... from typing import Self, reveal_type class Foo: def return_self(self) -> Self: ...
🌐
Javatpoint
javatpoint.com › pythons-self-type
Python's Self Type | Annotate Method That Return Self Type - Javatpoint
Python's Self Type | Annotate Method That Return Self Type with Codes in Python with tutorial, tkinter, button, overview, canvas, frame, environment set-up, first python program, etc.
🌐
Medium
medium.com › @asierr › pythons-self-type-how-it-makes-object-oriented-programming-better-f2f1bbba8472
Python’s Self Type: How It Makes Object-Oriented Programming Better | by asierr.dev | Medium
February 15, 2025 - Before Python 3.13, developers ... class. The new Self type simplifies this process by providing an explicit way to indicate that a method returns the current instance....
Find elsewhere
🌐
YouTube
youtube.com › indently
How To Use The NEW "Self" Type In Python 3.11 (NEW FEATURE!) - YouTube
Python 3.11 introduced to us a new Self type that we can use with classes. Let's take a good look at how we can use it!▶ Become job-ready with Python:https:/...
Published: November 28, 2022
Views: 16K
🌐
Medium
medium.com › @techclaw › self-type-in-python-simplifying-object-oriented-programming-bf56b210ee3d
Self Type in Python: Simplifying Object-Oriented Programming | by TechClaw | Medium
September 28, 2023 - It represents the instance of the class itself. When defining methods within a class, you must always include “Self” as the first parameter, which refers to the instance invoking the method.
🌐
Python.org
discuss.python.org › typing
Using `Self` with classmethod and a `Self` class attribute - Typing - Discussions on Python.org
June 16, 2024 - Hello, I’m trying to type the following code, where a class has a class attribute containing a reference to itself (something like a Singleton for instance). It would look like this: from typing import Self class MyClass: _singleton: Self | None = None @classmethod def new(cls) -> Self: if ...
🌐
Reddit
reddit.com › r/python › pep 673 -- self type
r/Python on Reddit: PEP 673 -- Self Type
November 11, 2021 - This behaves the same as the TypeVar-based approach specified in PEP 484 but is more concise and easier to follow. Self used in the signature of a method is treated as if it were a TypeVar bound to the class.
🌐
Rednafi
rednafi.com › home › python › self type in python
Self type in Python | Redowan's Reflections
June 30, 2026 - PEP-673 introduces the Self type and it’s coming to Python 3.11.
🌐
Reddit
reddit.com › r/learnpython › the self type in python 3.11
r/learnpython on Reddit: The Self type in Python 3.11
April 22, 2025 -

So, this was one of the new features added in Python 3.11.

I understand that it's whole purpose is to avoid typing class name as a string (e.g. "Shape"), but use Self type directly (which is a local alias to Shape).

I understand it is mainly useful in the following scenarios:

I. Implementing fluent interfaces (when each method returns the object itself, so multiple method calls could be chained):

class Shape:
    def set_size(self, size: float) -> Self:
        self.size = size * 100.0  # normalize
        return self

II. Implementing factory methods:

class Shape:
    @staticmethod  # or @classmethod
    def load_from_disk(filename: string) -> Self:
        obj = decrypt_and_deserialize(filename)
        return obj

But are there any other useful use cases?

Shall I annotate each self parameter of each class method with Self?

Shall __new__() method be returning Self?

🌐
W3Schools
w3schools.com › python › gloss_python_self.asp
Python Self
Python Examples Python Compiler ... Training ... The self parameter is a reference to the current instance of the class, and is used to access variables that belongs to the class....
🌐
GitHub
github.com › python › mypy › issues › 11871
support pep 673 Self type · Issue #11871 · python/mypy
December 29, 2021 - Support the pep-673 Self type · pep is at: https://www.python.org/dev/peps/pep-0673/ a rough idea of it is that this code: from typing import Self class Widget: def add_thing(self, value: str) -> Self: self.value = value return self · is quasi-equivalent to: from typing import TypeVar TWidget = TypeVar("TWidget", bound="Widget") class Widget: def add_thing(self: TWidget, value: str) -> TWidget: self.value = value return self ·
Author: python
🌐
GitHub
github.com › python › mypy › issues › 16558
`Self` type isn't considered to be the same as the explicit class type · Issue #16558 · python/mypy
November 25, 2023 - To work around this, one must use typing.cast or # type: ignore comments. Furthermore, within those same methods returning Self, the self parameter auto-magically assumes the type of Self, to accommodate the fact that Self is seen by mypy as a TypeVar and "A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]".
Author: python
🌐
GeeksforGeeks
geeksforgeeks.org › self-in-python-class
self in Python class - GeeksforGeeks
February 26, 2025 - Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made. Each class instance can have attributes attached to ... In Python, self is a fundamental concept when working with object-oriented programming (OOP).
🌐
GitHub
github.com › python › typing › issues › 271
A way to spell "SelfType", the type of self · Issue #271 · python/typing
August 28, 2016 - The proposal does not require changes ... simple: in an instance method, you can add a type annotation for self which is a type variable, and make the return type use that same type variable, e.g....
Author: python
🌐
Reddit
reddit.com › r/python › pep 673 -- self type (accepted)
r/Python on Reddit: PEP 673 -- Self Type (Accepted)
January 24, 2022 - Python has a superior way to accomplish the same design goal using kwargs. ... Basically any language can use that pattern. It's common in Rust too. ... This is a very common format. See Pandas, NumPy, and many, many other libraries - in fact, there are over 700 matches for "Self" in the standard library types (typeshed) alone.
🌐
Glyphack
glyphack.com › ty-self
Adding Support for Self to Ty | Glyphack
September 18, 2025 - A type checker is full of exceptions and special cases already and being able to remove problems like this is a good thing. So that’s how Ty binds the Self argument. The next part of this change is unannotated self usage. Most Python code in the wild does not annotate the self argument with typing.Self so the self argument is considered to have this type annotation implicitly.