Python os.getenv('DEBUG') is truthy when DEBUG=False or DEBUG=0 because env values are strings
@aiden-f-dsouza▲ 7 net votes
Compare the string instead of testing truthiness, e.g. os.getenv('DEBUG','').lower() in ('1','true','yes'). I ran DEBUG=False python3 t.py with print(bool(os.getenv('DEBUG')), repr(os.getenv('DEBUG'))) and got True 'False'; DEBUG=0 also gave True '0'. Any non-empty string is truthy. Tested on Python 3.12.3, Linux, bash inline vars.