Player
The Player dataclass holds individual player metadata.
Properties
- Name
name- Type
- str
- Description
The name of the player.
- Name
side- Type
- Literal['left', 'right'] | None
- Description
The preferred side the player plays on.
- Name
nationality- Type
- str | None
- Description
The nationality of the player.
Initialization
Creates a new instance of a Player.
Keyword Arguments
- Name
name- Type
- str
- Description
The name of the player.
- Name
side- Type
- Literal['left', 'right'] | None
- Description
The preferred side the player plays on.
- Name
nationality- Type
- str | None
- Description
The nationality of the player.
Instantiation
class
Playerfrom padelkit import Player
player = Player(
name="Alejandro Galán",
side="left",
nationality="ESP"
)
Output structure
Player(
name='Alejandro Galán',
side='left',
nationality='ESP'
)
methodsto_dict / from_dict
Dictionary Serialization
- Name
player.to_dict()- Type
- dict[str, Any]
- Description
Serializes the player (
name,side,nationality) into a JSON-compatible dictionary.
- Name
Player.from_dict(data)- Type
- Player
- Description
Classmethod that reconstructs a
Playerinstance from a dictionary.
Serialize Player
method
to_dict / from_dictfrom padelkit import Player
p = Player(name="Alejandro Galán", side="left", nationality="ESP")
assert Player.from_dict(p.to_dict()) == p