That would be great to extend current syntaxis with standart python dictionary's.
For now we can work with .env vars like this: os.getenv('value') or os.environ.get('value').
But .get() methods handles KeyError exceptions, so, we can't autocheck .env file correctness.
All we can do is to write smth like that:
foo = os.getenv('bar', None)
if foo is None:
raise KeyError('bar')
But, this of cource this ruins the code clearness/elegancy.
So, the main idea is to extend support for python dictionary syntaxis, which will looks like that: os.environ['value'].
This syntax will throw the exception in case of incorrect .env key.
That would be great to extend current syntaxis with standart python dictionary's.
For now we can work with .env vars like this:
os.getenv('value')
oros.environ.get('value')
. But.get()
methods handles KeyError exceptions, so, we can't autocheck .env file correctness.All we can do is to write smth like that:
But, this of cource this ruins the code clearness/elegancy.
So, the main idea is to extend support for python dictionary syntaxis, which will looks like that:
os.environ['value']
. This syntax will throw the exception in case of incorrect .env key.