From the documentation:
If the platform supports the
unsetenv()
function, you can delete items in this mapping to unset environment variables.unsetenv()
will be called automatically when an item is deleted from os.environ, and when one of thepop()
orclear()
methods is called.
However I want something that will work regardless of the availability of unsetenv()
. How do I delete items from the mapping if it's not available? os.environ['MYVAR'] = None
?
Using the set -n command Alternatively, you can unset environment variables by using the set command with the “-n” flag.
It is very simple to delete environment variables. You need to just use the unset command with the variable name to delete it. This command will remove the variable permanently.
The dsadmin command can be used for deleting an environment variable in a particular project.
Just
del os.environ['MYVAR']
should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With