I have an updated version of this on my blog here: https://chrisamico.com/blog/2023-01-14/python-setup/.
This is my recommended Python setup, as of Fall 2022. The Python landscape can be a confusing mess of overlapping tools that sometimes don't work well together. This is an effort to standardize our approach and environments.
- Python docs: https://docs.python.org/3/
- Python Standard Library: - Start here when you're trying to solve a specific problem
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
| # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.154.2/containers/python-3/.devcontainer/base.Dockerfile | |
| # [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6 | |
| ARG VARIANT="3" | |
| FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} | |
| # [Option] Install Node.js | |
| ARG INSTALL_NODE="true" | |
| ARG NODE_VERSION="lts/*" | |
| RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi |
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
| #!/bin/sh | |
| # This creates a GKE Cluster | |
| # - Will wait for any deletion to complete on a cluster with the same name before creating | |
| # - Will wait for completion before continuing | |
| # - If the script is run concurrently multiple times, only one cluster will be created, all instances will wait for availability | |
| # Requires GCP Cloud SDK | |
| # Installs retry https://github.com/kadwanev/retry | |
| export GKE_PROJECT=$1 |
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
| #!/bin/bash | |
| # BEGIN SANITY BOX------------------------------------------ | |
| set -e # immediately exit if any command fails | | |
| set -u # immediately fail on undefined variables | | |
| set -o pipefail # show error of last failed command | | |
| IFS=$'\n\t' # control what word splitting means | | |
| # END SANITY BOX-------------------------------------------- | |
| # delete |
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
| # Python 3.5.2-slim | |
| import json | |
| from tornado.httpclient import HTTPClient | |
| response = HTTPClient().fetch("https://www.howsmyssl.com/a/check").body.decode() | |
| data = json.loads(response) | |
| tls_version = data["tls_version"] | |
| print(tls_version)" # TLS 1.2 |