I have abstracted the reading of the .env
file to settings.py
but I'm not sure if this is idiomatic to python:
# .env
SECRET=XXXX
# settings.py
import os
from os.path import join, dirname
from dotenv import load_dotenv
dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)
SECRET = os.environ.get("SECRET_KEY")
# app.py
from ..settings import CONSUMER_KEY
def useSecret(SECRET):
Should each module read the .env
file directly?