About 2,230,000 results
Open links in new tab
  1. How do I create a constant in Python? - Stack Overflow

    Apr 21, 2010 · In Python, constants do not exist, but you can indicate that a variable is a constant and must not be changed by adding CONST_ to the start of the variable name and stating that it is a …

  2. what is the best way to define constant variables python 3

    Python does not allow constant declarations like C or C++. Normally in Python, constants are capitalized (PEP 8 standards) which helps the programmer know it's a constant.

  3. python - Best/Cleanest way to define constant lists or dictionaries ...

    5 Make a separate file constants.py, and put all globally-relevant constants in there. Then you can import constants to refer to them as constants.SPAM or do the (questionable) from constants import …

  4. What's the best way to initialise and use constants across Python ...

    Oct 16, 2018 · Here's how I am declaring constants and using them across different Python classes: # project/constants.py GOOD = 1 BAD = 2 AWFUL = 3 # project/question.py from constants import …

  5. python - What are constants and literal constants? - Stack Overflow

    Jun 9, 2014 · I have been learning the Python language using the "A byte of python" book and somewhere in the book I came across a section which talks about literals and constants.I share the …

  6. What is the naming convention in Python for variables and functions ...

    As the Style Guide for Python Code admits, The naming conventions of Python's library are a bit of a mess, so we'll never get this completely consistent Note that this refers just to Python's standard …

  7. How can I implement true constants in Python? - Stack Overflow

    Apr 6, 2025 · Python is not immutable, and that can have unintended value mutations—particularly in big codebases. So I made setconstant, a light Python package allowing you to define true constants that …

  8. How do you declare a global constant in Python?

    Jun 10, 2014 · My program contains multiple files and classes, and I would like to be able to access this variable from anywhere, and if possible define it as constant. How do you define a global constant in …

  9. How to document a module constant in Python? - Stack Overflow

    I have a module, errors.py in which several global constants are defined (note: I understand that Python doesn't have constants, but I've defined them by convention using UPPERCASE). """Indicates ...

  10. Conventions on creating constants in Python - Stack Overflow

    Aug 16, 2011 · 20 Constants generally go at the module level. From : Constants Constants are usually defined on a module level and written in all capital letters with underscores separating words. …