Working With Constants in Python

Sdílet
Vložit
  • čas přidán 14. 07. 2024
  • This is a preview of the video course, "Defining Python Constants for Code Maintainability." In programming, the term constant refers to names representing values that don’t change during a program’s execution. Constants are a fundamental concept in programming, and Python developers use them in many cases. However, Python doesn’t have a dedicated syntax for defining constants. In practice, Python constants are just variables that never change.
    This is a portion of the complete course, which you can find here:
    realpython.com/courses/defini...
    The rest of the course covers:
    - Properly define constants in Python
    - Identify some built-in constants
    - Use constants to improve your code’s readability, reusability, and maintainability
    - Apply different approaches to organize and manage constants in a project
    - Use several techniques to make constants strictly constant in Python

Komentáře • 5

  • @NicolasChanCSY
    @NicolasChanCSY Před 9 dny +1

    We can also make use of the `typing.Final` type annotation to indicate a variable is not supposed to be change.
    Type checkers will raise an error message if the variable is reassigned, redefined, or overridden. While this cannot stop any change in run-time, it certainly helps identify such unintended behaviour early in compile-time.

  • @ag49521
    @ag49521 Před 9 dny

    I didn't know you could make a 15 min video about constants.

  • @serychristianrenaud
    @serychristianrenaud Před 10 dny

    Thanks

  • @rishiraj2548
    @rishiraj2548 Před 10 dny

    Good day greetings

  • @alcar32sharif
    @alcar32sharif Před 10 dny +1

    Constants are a lie in Python. Every variable is reassignable.