Self
In Python, self conventionally names the current object in an instance method, while Self denotes the enclosing class and associated instance types.
Python How-To
Self is a typing construct that denotes the enclosing class and the type of instances or class-level results associated with it.
- How it is used
- Identifies the instance that an initializer or instance method operates on.
- How deep it goes
- Explains implicit argument passing through construction and method calls, including an object-identity check.
- Examples
- Uses a task class, matching object addresses, and a task-completion method.
- What you can do after
- Build it from scratch: define instance methods that initialize or update the object on which they are called.
Practices of the Python Pro
self is the conventional name for the Python method parameter that refers to the current object instance.
- How it is used
- Uses self to connect class methods with the current object’s data and behavior.
- How deep it goes
- Explains self through class methods, initialization, attribute access, and a small game simulator.
- Examples
- Demonstrates self with a RockPaperScissorsSimulator that stores and prints human and computer choices.
- What you can do after
- Apply it via Python to initialize, update, and read data belonging to a particular object instance.
Related concepts
- objectuses · A computational object is a runtime entity or structured value representing data, state, or a resource, with properties or operations defined by its programming model.
- methodused by · A method is a callable operation associated with an object or type and invoked through that association.
- self parametercontrasts with · A self parameter is a method receiver representing the instance or object on which the method operates or is invoked.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

