Python - Classes and Objects
Code Life
By Pierre Marsaa
What is a Class?
Until now, you've used Python's built-in types: str, int, list... But what if you want to create your own type? Imagine you want to represent a Codémon — it has a name, a type, a level. You could use a dictionary... but Python lets you create a class instead!
A class is like a blueprint. Just like a Codémon blueprint describes what every Codémon should have (name, type, level), a class describes what your custom objects should look like.
↗️
Loading editor...
↶
↷
We just created our first class! class Codemon: defines the blueprint. Codemon() creates an object (also called an instance) from that blueprint.
OOP meaning
OOP stands for Object-Oriented Programming. It's the programming paradigm we are going to talk about in the few next chapters. It organizes code around objects and their interactions.
Verify