liveBook · Manning

Self parameter

A self parameter is a method receiver representing the instance or object on which the method operates or is invoked.

How 3 Manning books explain it

Python Workout: 50 ten-minute exercises

self is the conventional first parameter of a Python instance method that refers to the instance on which the method was invoked.

How it is used
Uses self to attach state to instances and let inherited methods select instance- or class-specific attributes.
How deep it goes
Explains parameter binding, attribute creation, lookup, inheritance, and object initialization, while stopping short of detailed method-binding internals.
Examples
Demonstrates Scoop and Person initialization, Foo attribute access, Bowl lookup, and inherited Animal representations.
What you can do after
Apply self in instance methods to initialize attributes, access object state, and reuse behavior across subclasses.

Read how Python Workout: 50 ten-minute exercises explains self parameter →

The Quick Python Book, Fourth Edition

self is the conventional first parameter name that refers to the instance on which a Python method is invoked.

How it is used
Identifies the current instance when methods initialize or use its fields.
How deep it goes
Explains implicit argument passing, explicit class-based calls, and namespace access without descending into method implementation internals.
Examples
Uses a circle’s radius and area to distinguish `self.radius` from a local parameter and compare method-call forms.
What you can do after
Evaluate/understand it when reading method definitions and calls, including which instance supplies a method’s first argument.

Read how The Quick Python Book, Fourth Edition explains self parameter →

Get Programming: Learn to code with Python

self is the conventional first parameter of a Python instance method that refers to the instance on which the method is called.

How it is used
Uses self to connect class methods with each object's data and operations.
How deep it goes
Explains declarations, attribute access, automatic argument assignment, and per-instance effects through small class examples.
Examples
Uses Circle and Door classes, radius attributes, method calls, independent instances, and short method-writing exercises.
What you can do after
Build instance methods that initialize, change, retrieve, and calculate values stored on individual objects.

Read how Get Programming: Learn to code with Python explains self parameter →

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.