Python · Stage 9 – Intro to Objects · Lesson 45 of 50

Classes and Objects

Understand a class as a blueprint and an object as one created instance.

class Dog:
    pass
Line-by-line explanation
  1. class begins a class definition.
  2. Dog is the class name.
  3. The colon begins its indented body.
  4. pass is a do-nothing placeholder.
pet = Dog()
Line-by-line explanation
  1. Dog() creates one instance.
  2. pet stores that object.