Making Self Work
Introduction: Putting self to Work
Welcome back to Understanding "self" in Python! We are now at the halfway point of the course. In Unit 2, we proved what self is: a plain reference to the object sitting before the dot. In this unit, we finally put that reference to work.
Three new skills are waiting for us:
- Methods that change their own object's attributes, not just read them.
- Methods that accept extra arguments alongside
self. - Methods that call other methods on the same object through
self.
Our running example will be a small Robot class with two attributes, name and version, which we will grow one method at a time.
Starting Point: A Class With a Reading Method
Let us begin where the last unit left off, with a method that only reads. describe looks up two attributes on the receiving object and returns a sentence built from them.
As in the earlier course, we create an instance and attach its attributes with dot notation. Then unit_one.describe() hands unit_one over as self, so self.name reads "Unit-1" and self.version reads 1.0.
Nothing about the robot changes here: the method reads through self and returns a fresh string.
A Method That Changes Its Own Object
Reading is only half the story. Since self points at the real object, we can also assign through it. Let us add an upgrade method that bumps the version number.
That single line performs a read, a modification, and a store, all on the receiving object: it reads self.version, adds 1.0, and writes the result back onto the same object. In the previous course, we did this with a top-level function such as upgrade(robot); the logic is identical, but now the object arrives automatically as self.
Notice also that upgrade has no return statement, so it returns None. Its purpose is the side effect on the object, not a value we print.
Methods That Accept Extra Arguments

