Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow opening other files, not just .env #66

Closed
nvtkaszpir opened this issue Mar 19, 2019 · 3 comments · Fixed by #77
Closed

Allow opening other files, not just .env #66

nvtkaszpir opened this issue Mar 19, 2019 · 3 comments · Fixed by #77

Comments

@nvtkaszpir
Copy link
Contributor

Currently environs read only hard-coded .env files, and only path is available.
Yet more and more tools allow custom .env files.

I believe environs should add parameter like file='.env' to be able to override defaults.

@c-w
Copy link
Contributor

c-w commented May 15, 2019

Note that it's already possible to read files not called .env when using recurse=False, so perhaps that offers a work-around:

from environs import Env

with open("test.txt", "w") as fobj:
    fobj.write("A=foo\n")
    fobj.write("B=123\n")

env = Env()
env.read_env("test.txt", recurse=False)

assert env("A") == "foo"
assert env.int("B") == 123

@nvtkaszpir
Copy link
Contributor Author

Oh right, that's PEBKAC from my point. I was totally not seeing part of the code.

I believe this should be added to the docs as an example.

@sloria
Copy link
Owner

sloria commented May 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants