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
Uses self to access and initialize the current instance in Python methods.
How deep it goes
Explains implicit and explicit instance passing, attribute lookup, and private superclass names.
Examples
Demonstrates a Circle initializer and area method, including calls through an instance and its class.
What you can do after
Practice defining and calling instance methods that initialize and use instance attributes.

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 →

Also covered in

What to know first

Related concepts

Questions about self parameter

What is self parameter?

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

Which Manning books explain self parameter?

Python Workout: 50 ten-minute exercises, The Quick Python Book, Fourth Edition and Get Programming: Learn to code with Python.

What should I know before learning self parameter?

Manning books that teach self parameter usually introduce attribute, method, comprehension and default value first.

What is the difference between self parameter and mutable reference?

A self parameter is a method receiver representing the instance or object on which the method operates or is invoked. A mutable reference is a reference or handle that provides access to a value or storage location that can be modified, subject to the language’s access rules.

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.