A class in Python is a blueprint for creating objects, defined with the class keyword.
This page covers Class in Python. For a language-agnostic introduction, see Class.
Defining a Class#
class Player:
passpass is a placeholder that means “empty body”. By convention, class names use PascalCase: Player, OddsAndEvens, RockPaperScissors.
Adding a Constructor#
In Python, the constructor is a special
method called __init__. It runs automatically when an object is created. The first parameter is always self — a reference to the object being created.