Short syntax examples of named tuples in Python 3. Supporting content for this blog post.
Syntax varies between Python 3.5, 3.6, and 3.7.
Named tuples are defined in Python's collections module.
Available in Python 3 and up.
Named tuples can be created with typing using Python's typing module.
Available in Python 3.6 and up.
A typed class can be created using Python's dataclass module.
Available in Python 3.7 and up.
Docker containers allow multiple versions of Python to be run on the same machine. Find official Python images on Docker Hub.
One approach is to bind mount the current directory to the container:
$ docker run --rm -it -w /usr/src --mount type=bind,src=$PWD,dst=/usr/src IMAGE_NAME bashThis runs an interactive shell in the container and allows you to run all scripts in the current directory.
Alternatively, run an individual script once:
$ docker run --rm -w /usr/src --mount type=bind,src=$PWD/SCRIPT_NAME,dst=/usr/src/example.py IMAGE_NAME python example.py