We initialize an object by implementing the __init__() method. When an object is created, Python first creates an empty object and then calls the __init__() method to set the state of the new object. This method generally creates the object's instance variables and performs any other one-time processing.
The following are some example definitions of a Card class hierarchy. We'll define a Card superclass and three subclasses that are variations of the basic theme of Card. We have two instance variables that have been set directly from argument values and two variables that have been calculated using an initialization method:
from typing import Tuple
class Card:
def __init__(self, rank: str, suit: str) -> None:
self.suit = suit
self.rank = rank
self.hard, self.soft = self._points()
def _points(self) ...