Fix Python – Securely storing environment variables in GAE with app.yaml

I need to store API keys and other sensitive information in app.yaml as environment variables for deployment on GAE. The issue with this is that if I push app.yaml to GitHub, this information becomes public (not good). I don’t want to store the info in a datastore as it does not suit the project. Rather, I’d like to swap out the values from a file….

Fix Python – What is the correct way to unset a linux environment variable in python?

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 the pop() or clear() methods is called.

However I want something that will work regardless of the availabil….

Fix Python – Parse config files, environment, and command-line arguments, to get a single collection of options

Python’s standard library has modules for configuration file parsing (configparser), environment variable reading (os.environ), and command-line argument parsing (argparse). I want to write a program that does all those, and also:

Has a cascade of option values:

default option values, overridden by
config file options, overridden by
environment ….

Fix Python – How to enable a virtualenv in a systemd service unit?

I want to “activate” a virtualenv in a systemd service file.
I would like to avoid having a shell process between the systemd process and the python interpreter.
My current solution looks like this:

WorkingDirectory={{ venv_home }}
ExecStart={{ ….

Fix Python – How to get the PATH environment-variable separator in Python?

When multiple directories need to be concatenated, as in an executable search path, there is an os-dependent separator character. For Windows it’s ‘;’, for Linux it’s ‘:’. Is there a way in Python to get which character to split on?
In the discussions to this question How do I find out my python path using python? , it is suggested that os.sep w….

Fix Python – What is a good practice to check if an environmental variable exists or not?

I want to check my environment for the existence of a variable, say “FOO”, in Python. For this purpose, I am using the os standard library. After reading the library’s documentation, I have figured out 2 ways to achieve my goal:
Method 1:
if “FOO” in os.environ:

Method 2:
if os.getenv(“FOO”) is not None:

I would like to know ….