Introduction to Python ProgrammingXYZ Homework Edition

⇩ Download ▾

11.3 Instance methods

Learning objectives

By the end of this section you should be able to

  • Create and implement __init__() with multiple parameters including default parameter values.
  • Describe what information an instance method has access to and can modify.

More about __init__

In Python, __init__() is the special method that creates instances. __init__() must have the calling instance, self, as the first parameter and can have any number of other parameters with or without default parameter values.

Instance methods

An instance method is used to access and modify instance attributes as well as class attributes. All methods shown so far, and most methods defined in a class definition, are instance methods.

Adapted from Introduction to Python Programming by OpenStax (openstax.org), licensed under CC BY-NC-SA 4.0. Changes were made. License: CC-BY-NC-SA-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or any other accessibility standard. Every page is built against an automated accessibility gate, and our target for the published editions is WCAG 2.2 Level AA. If something is unusable, please tell us.