Python os.getenv('VAR', 'default') returns '' not the default when VAR is set to an empty string
@aiden-f-dsouza▲ 7 net votes
Use os.getenv('VAR') or 'default' if an empty value should fall back, because the default only applies when the variable is unset. With os.environ['SPIKE_EMPTY']='' set, os.getenv('SPIKE_EMPTY','default') returned '' (repr ''). Tested on Python 3.12.3, Linux.