From b22600eb3803d0781d445e4944a19aaa9dab594d Mon Sep 17 00:00:00 2001 From: Andrew Neitsch Date: Wed, 23 May 2018 17:00:08 -0600 Subject: [PATCH] Add python 3.7 example --- presentation/presentation.tex | 5 +++++ python-3.7/dataclass_example.py | 14 ++++++++++++++ python-3.7/run | 6 ++++++ 3 files changed, 25 insertions(+) create mode 100644 python-3.7/dataclass_example.py create mode 100755 python-3.7/run diff --git a/presentation/presentation.tex b/presentation/presentation.tex index 5616d78..f29f0b2 100644 --- a/presentation/presentation.tex +++ b/presentation/presentation.tex @@ -174,8 +174,13 @@ \section{Docker} docker run --rm -it --link my-tmp-db \ mysql \ mysql -h my-tmp-db -px + +docker run ... python:3.7-rc-alpine ... + \end{verbatim} +\pause + \end{frame} \begin{frame}{Big benefit for everyone} diff --git a/python-3.7/dataclass_example.py b/python-3.7/dataclass_example.py new file mode 100644 index 0000000..a127dd1 --- /dev/null +++ b/python-3.7/dataclass_example.py @@ -0,0 +1,14 @@ +from dataclasses import dataclass + +@dataclass +class InventoryItem: + '''Class for keeping track of an item in inventory.''' + name: str + unit_price: float + quantity_on_hand: int = 0 + + def total_cost(self) -> float: + return self.unit_price * self.quantity_on_hand + +i = InventoryItem(name='Socks', unit_price=12.75, quantity_on_hand=14) +print(f"${i.total_cost()} worth of {i.name} on hand") diff --git a/python-3.7/run b/python-3.7/run new file mode 100755 index 0000000..52064c9 --- /dev/null +++ b/python-3.7/run @@ -0,0 +1,6 @@ +#!/bin/bash + +DIR="$(cd "$(dirname -- "${0}")" && pwd)" + +exec docker run --rm -v $DIR:/app python:3.7-rc-alpine python \ + /app/dataclass_example.py