Last active
September 25, 2022 03:25
-
-
Save Ichinga-Samuel/ec98c14a4fc3b657d6b3e7fd10c50f34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import environ | |
from dotenv import load_dotenv, dotenv_values | |
class Config: | |
def __init__(self): | |
load_dotenv() | |
# setup non secret config variables here | |
self.public = "public" | |
[setattr(self, key, value) for key, value in dotenv_values('config.env').items()] | |
def __getattr__(self, item): | |
attr = environ.get(item.upper()) | |
setattr(self, item, attr) if attr is not None else ... # this is not really necessary | |
return attr | |
env = Config() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment