My App
Phase 4 — Python OOP

class & object

Defining a class, and creating an object from it — no new keyword

class

A class is a blueprint for creating objects. The keyword is the same word you already know:

TypeScript:

class User {
}

Python:

class User:
    pass

Same pattern as functions: : + indentation instead of { }. pass just means "empty body for now" (you saw this back in Phase 1).

object

An object (Python calls it an instance) is a real value created from a class.

TypeScript:

const user = new User();

Python:

user = User()

The one thing to unlearn: Python has no new keyword. Calling the class name like a function creates the object.

On this page