liveBook · Manning

Self

In Python, self conventionally names the current object in an instance method, while Self denotes the enclosing class and associated instance types.

How 2 Manning books explain it

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.

Read how Python How-To explains self →

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.

Read how Practices of the Python Pro explains self →

Related concepts

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.