Skip to main content

Attributes: storing data

Attributes are variables that belong to an object. There are two types: Instance attributes (unique to each object):
Class attributes (shared by all objects):

Methods: adding behavior

Methods are functions that belong to a class. They always have self as the first parameter, but you don’t pass it when calling:
When you call a method like validator.validate_email("test@example.com"), Python automatically passes the validator object as self. You only provide the other arguments.

Common mistakes

What’s next?

Let’s explore inheritance - how classes can build on other classes.

Inheritance

Build on existing classes