![]() DATABASE_HOST ) # Will print '10.0.0.1' print ( settings. Import the settings module and access directly to your properties: from python_settings import settings print ( settings. configure ( my_local_settings ) # configure() receives a python module assert settings. import settings as my_local_settings settings. ![]() Calling the configure function from our settings module and passing it your python file from python_settings import settings from. Įxample in bash: export SETTINGS_MODULE =settingsĮxample in Python import os os. You must have an environment variable called SETTINGS_MODULE and as a value your just created python settings file in the format. Two optional patterns to initialize this library It is based onĬlone this repo and type python setup.py installĬreate a python file like settings.py in your project, the variable names must be in Capital Letters (A-Z), example: # settings.py # Variables definition DATABASE_HOST = '10.0.0.1' DATABASE_NAME = 'DATABASENAME' This module provides you easy access to your config/settings properties from all your python modules, it supports normal and lazy initialization for each property.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |