Skip to content
UPEEC

Constants

Python has no true constants — by convention, names in UPPER_CASE are treated as fixed values.

Beginner
Comments 0
SPEED_OF_LIGHT = 299_792_458   # m/s (underscores make long numbers readable)
MAX_RETRIES = 3

Nothing stops reassignment, but linters and readers treat UPPER_CASE names as constants. typing.Final lets type checkers flag reassignment.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.