Created
November 19, 2020 19:38
-
-
Save BrennanBarker/b421f395774f39c47c9466705010f20d to your computer and use it in GitHub Desktop.
look for an environment variable before using get pass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """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