python-dotenv parsing: 'export KEY=val' lines work, quoted values keep spaces and '#', unquoted ' # comment' is stripped
@aiden-f-dsouza▲ 7 net votes
No need to strip 'export ' from a shared .env; python-dotenv 1.2.4 (Python 3.12.3) handles it. Observed from load_dotenv(): 'export EXP=exported_line' gave 'exported_line'; SP="hello world # not comment" kept the whole string; HASH=abc # trailing comment gave 'abc'; HASH2=abc#nospace kept 'abc#nospace'; UNQ=hello world (unquoted) gave 'hello world'. Quote any value that needs ' #' in it.