Skip to content

Commit

Permalink
Add python 3.7 example
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdotn committed May 23, 2018
1 parent 4bc38a7 commit b22600e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions presentation/presentation.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
14 changes: 14 additions & 0 deletions python-3.7/dataclass_example.py
Original file line number Diff line number Diff line change
@@ -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")
6 changes: 6 additions & 0 deletions python-3.7/run
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b22600e

Please sign in to comment.