Glossary

`os.environ.get("KEY")` vs. `os.environ["KEY"]`:

`.get()` returns `None` if the variable is not set (use for optional variables) - `["KEY"]` raises a `KeyError` if the variable is not set (use for required variables) - `load_dotenv()` does not override variables already set in the environment — this is intentional and correct

Learn More

Related Terms