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

    Apr 21, 2010 · 1440 You cannot declare a variable or value as constant in Python. To indicate to programmers that a variable is a constant, one usually writes it in upper case:

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

    I am writing a program in python which contains many constant variables. I would like to create a file that will hold all these variables like the .h file in C that contains many #define. I tried t...

  3. 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 …

  4. Why constants in Python can be changed? - Stack Overflow

    Apr 9, 2023 · A constant is a variable whose value stays the same throughout the life of a program. Python doesn’t have built-in constant types, but Python programmers use all capital letters to …

  5. Conventions on creating constants in Python - Stack Overflow

    Aug 16, 2011 · Conventions on creating constants in Python Asked 14 years, 6 months ago Modified 11 years, 6 months ago Viewed 36k times

  6. python - How to use values stored in variables as case patterns ...

    14 Python's match is much more than a simple switch statement. If you use bare what you consider "variable names", they are actually going to be Capture Patterns. Besides the fact that you should …

  7. 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 …

  8. python - Global variables and coding style recommendations - Stack …

    Mar 20, 2013 · I usually start like this for small scripts, and as the code grows, I encapsulate it in a class so that the global variable becomes a class variable.

  9. Class constants in Python - Stack Overflow

    May 20, 2012 · In Python, I want a class to have some "constants" (practically, variables) which will be common in all subclasses. Is there a way to do it with friendly syntax?

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

    Thank you blender. Quick curiosity question, if I assign a local variable (within a function) to that imported global variable, will that local var have a copy or a reference to the global?