Python Snippets

Virtual Environments Create and activate a venv python -m venv /path/to/new-env (1) source /path/to/new-env/bin/activate (2) 1 Creates a new virtual environment 2 Activate the new virtual environment Deactivate venv deactivate Save used dependencies to a file pip freeze > dependencies.txt Install dependencies from file pip install -r dependencies.txt Storing and fetching Credentials from the System Keyring I am using jaraco/keyring here: pip install keyring import keyring keyring.set_password("system", "db.sample.password", "xoxo") print(keyring.get_password("system", "db.sample.password")) ...

March 1, 2010 · 1 min · 100 words · Micha Kops