You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: clarify override behavior and document FIFO support
- Explicitly state that override=False is the default behavior in the
Getting Started section for better clarity
- Add note about FIFO (named pipes) support on Unix systems in the
File format section
- Improve formatting consistency:
- Standardize TOC list markers (use '-' instead of '*')
- Fix line wrapping and spacing issues throughout
To configure the development environment, add a `.env` in the root directory of your
52
-
project:
51
+
To configure the development environment, add a `.env` in the root directory of
52
+
your project:
53
53
54
54
```
55
55
.
56
56
├── .env
57
57
└── foo.py
58
58
```
59
59
60
-
The syntax of `.env` files supported by python-dotenv is similar to that of Bash:
60
+
The syntax of `.env` files supported by python-dotenv is similar to that of
61
+
Bash:
61
62
62
63
```bash
63
64
# Development settings
@@ -66,22 +67,21 @@ ADMIN_EMAIL=admin@${DOMAIN}
66
67
ROOT_URL=${DOMAIN}/app
67
68
```
68
69
69
-
If you use variables in values, ensure they are surrounded with `{` and `}`, like
70
-
`${DOMAIN}`, as bare variables such as `$DOMAIN` are not expanded.
70
+
If you use variables in values, ensure they are surrounded with `{` and `}`,
71
+
like `${DOMAIN}`, as bare variables such as `$DOMAIN` are not expanded.
71
72
72
-
You will probably want to add `.env` to your `.gitignore`, especially if it contains
73
-
secrets like a password.
73
+
You will probably want to add `.env` to your `.gitignore`, especially if it
74
+
contains secrets like a password.
74
75
75
-
See the section "File format" below for more information about what you can write in a
76
-
`.env` file.
76
+
See the section "[File format](#file-format)" below for more information about what you can write in a `.env` file.
77
77
78
78
## Other Use Cases
79
79
80
80
### Load configuration without altering the environment
81
81
82
-
The function `dotenv_values` works more or less the same way as `load_dotenv`, except it
83
-
doesn't touch the environment, it just returns a `dict` with the values parsed from the
84
-
`.env` file.
82
+
The function `dotenv_values` works more or less the same way as `load_dotenv`,
83
+
except it doesn't touch the environment, it just returns a `dict` with the
84
+
values parsed from the `.env` file.
85
85
86
86
```python
87
87
from dotenv import dotenv_values
@@ -104,9 +104,9 @@ config = {
104
104
105
105
### Parse configuration as a stream
106
106
107
-
`load_dotenv` and `dotenv_values` accept [streams][python_streams] via their`stream`
108
-
argument. It is thus possible to load the variables from sources other than the
109
-
filesystem (e.g. the network).
107
+
`load_dotenv` and `dotenv_values` accept [streams][python_streams] via their
108
+
`stream`argument. It is thus possible to load the variables from sources other
109
+
than the filesystem (e.g. the network).
110
110
111
111
```python
112
112
from io import StringIO
@@ -119,7 +119,7 @@ load_dotenv(stream=config)
119
119
120
120
### Load .env files in IPython
121
121
122
-
You can use dotenv in IPython. By default, it will use `find_dotenv` to search for a
122
+
You can use dotenv in IPython. By default, it will use `find_dotenv` to search for a
123
123
`.env` file:
124
124
125
125
```python
@@ -140,12 +140,14 @@ Optional flags:
140
140
141
141
### Disable load_dotenv
142
142
143
-
Set `PYTHON_DOTENV_DISABLED=1` to disable `load_dotenv()` from loading .env files or streams. Useful when you can't modify third-party package calls or in production.
143
+
Set `PYTHON_DOTENV_DISABLED=1` to disable `load_dotenv()` from loading .env
144
+
files or streams. Useful when you can't modify third-party package calls or in
145
+
production.
144
146
145
147
## Command-line Interface
146
148
147
-
A CLI interface `dotenv` is also included, which helps you manipulate the `.env` file
148
-
without manually opening it.
149
+
A CLI interface `dotenv` is also included, which helps you manipulate the `.env`
150
+
file without manually opening it.
149
151
150
152
```shell
151
153
$ pip install "python-dotenv[cli]"
@@ -166,13 +168,13 @@ Run `dotenv --help` for more information about the options and subcommands.
166
168
167
169
## File format
168
170
169
-
The format is not formally specified and still improves over time. That being said,
170
-
`.env` files should mostly look like Bash files.
171
+
The format is not formally specified and still improves over time. That being
172
+
said, `.env` files should mostly look like Bash files. Reading from FIFOs (named pipes) on Unix systems is also supported.
171
173
172
-
Keys can be unquoted or single-quoted. Values can be unquoted, single- or double-quoted.
173
-
Spaces before and after keys, equal signs, and values are ignored. Values can be followed
174
-
by a comment. Lines can start with the `export` directive, which does not affect their
175
-
interpretation.
174
+
Keys can be unquoted or single-quoted. Values can be unquoted, single- or
175
+
double-quoted. Spaces before and after keys, equal signs, and values are
176
+
ignored. Values can be followed by a comment. Lines can start with the `export`
177
+
directive, which does not affect their interpretation.
176
178
177
179
Allowed escape sequences:
178
180
@@ -181,8 +183,8 @@ Allowed escape sequences:
181
183
182
184
### Multiline values
183
185
184
-
It is possible for single- or double-quoted values to span multiple lines. The following
185
-
examples are equivalent:
186
+
It is possible for single- or double-quoted values to span multiple lines. The
187
+
following examples are equivalent:
186
188
187
189
```bash
188
190
FOO="first line
@@ -201,26 +203,27 @@ A variable can have no value:
201
203
FOO
202
204
```
203
205
204
-
It results in `dotenv_values` associating that variable name with the value `None` (e.g.
205
-
`{"FOO": None}`. `load_dotenv`, on the other hand, simply ignores such variables.
206
+
It results in `dotenv_values` associating that variable name with the value
207
+
`None` (e.g. `{"FOO": None}`. `load_dotenv`, on the other hand, simply ignores
208
+
such variables.
206
209
207
-
This shouldn't be confused with `FOO=`, in which case the variable is associated with the
208
-
empty string.
210
+
This shouldn't be confused with `FOO=`, in which case the variable is associated
211
+
with the empty string.
209
212
210
213
### Variable expansion
211
214
212
215
python-dotenv can interpolate variables using POSIX variable expansion.
213
216
214
-
With `load_dotenv(override=True)` or `dotenv_values()`, the value of a variable is the
215
-
first of the values defined in the following list:
217
+
With `load_dotenv(override=True)` or `dotenv_values()`, the value of a variable
218
+
is the first of the values defined in the following list:
216
219
217
220
- Value of that variable in the `.env` file.
218
221
- Value of that variable in the environment.
219
222
- Default value, if provided.
220
223
- Empty string.
221
224
222
-
With `load_dotenv(override=False)`, the value of a variable is the first of the values
223
-
defined in the following list:
225
+
With `load_dotenv(override=False)`, the value of a variable is the first of the
226
+
values defined in the following list:
224
227
225
228
- Value of that variable in the environment.
226
229
- Value of that variable in the `.env` file.
@@ -229,26 +232,27 @@ defined in the following list:
229
232
230
233
## Related Projects
231
234
232
-
-[Honcho](https://github.com/nickstenning/honcho) - For managing
0 commit comments