Overview
Explore the concept of constants in Python through a comprehensive 24-minute video tutorial. Discover when and why to use constants instead of variables, and learn three practical implementations: frozen dataclasses, raising TypeError in __setattr__, and using typing.final. Gain insights into Python's design philosophy regarding constants and understand how to incorporate them into your programming toolkit. Follow along with code examples and explanations of the benefits and advantages of using constants in Python programming.
Syllabus
Intro
Background: const vs var
Why / when to use constants const?
Benefits / Advantages of const
dataclasses' frozen param Frozen dataclasses
raise TypeError in __setattr__
python's design philosophy on const
typing.final / @final decorator
from typing import Final typecheck
summary including const into your python programming toolkit
Taught by
Samuel Chan