What's the best way to initialise and use constants across Python classes?

后端 未结 4 1501
天涯浪人
天涯浪人 2020-12-30 18:46

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         


        
4条回答
  •  死守一世寂寞
    2020-12-30 19:37

    Try to look at the following links(one link contains a receipt from active state of how to implement a real constants):

    Importing a long list of constants to a Python file

    Create constants using a "settings" module?

    Can I prevent modifying an object in Python?

提交回复
热议问题