Create Enum constant in Flask/Python -


hi have file contain enum list of items using in configuration. e.g

{   "success": 1,   "failed": 1,   "pending": 1, } 

i wanted in laravel in place enum in 1 of files. in laravel can place inside folder config , file list_item e.g

return [   "success": 1,   "failed": 1,   "pending": 1, ] 

so if reference in laravel config('config.list_item') , contain array defined in list_item file. there way achieve same approach in python/flask? way can think of creating file , inside defining function example below

def statusenum():     return {        "success": 1,        "failed": 1,        "pending": 1,     } 

and referencing statusenum() want have cleaner way this.

so want cleaner , best approach have file contains enum list. wan't know how in python/flask.

you can use configparser stand library.

#config.cfg [status] failed = 0 success = 1 pending = 1  # python source code  import configparser config = configparser.configparser() config.read("config.cfg") config.getint("status", "failed") 

or place dict variable in configuration file. import want use it.

# config.py status = {"failed": 0, "success": 1, "pending": 2} 

from config import status  print(status["failed"]) 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -