Skip to content
dreamcode
dreamcode
Back to map
OOP · Lesson 29 of 44
+15 XP on finish
PYTHON INTERMEDIATE

Object-oriented programming

Python supports Object-Oriented Programming (OOP). Define a class using `class`, and initialize fields inside `__init__(self)`.

How it reads
def __init__(self, name) defines the constructor method
self refers to the specific instance of the object class
Cloud tip: Methods must receive self as their first parameter to access object fields.
main.py
PYTHON
real Python, runs in your browser
CONSOLE
- run your code to see output -