Skip to content

Instantly share code, notes, and snippets.

@BrennanBarker
Created November 19, 2020 19:38
Show Gist options
  • Select an option

  • Save BrennanBarker/b421f395774f39c47c9466705010f20d to your computer and use it in GitHub Desktop.

Select an option

Save BrennanBarker/b421f395774f39c47c9466705010f20d to your computer and use it in GitHub Desktop.
look for an environment variable before using get pass
"""First check environment variables for a password, if not then use `getpass`.
You might set the environment variable ahead of time with (from a shell)::
read -s secret
export secret
"""
import os, getpass
os.environ.get('secret') or getpass.getpass(prompt:"secret: ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment