Skip to content

Commit b22600e

Browse files
committed
Add python 3.7 example
1 parent 4bc38a7 commit b22600e

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

presentation/presentation.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,13 @@ \section{Docker}
174174
docker run --rm -it --link my-tmp-db \
175175
mysql \
176176
mysql -h my-tmp-db -px
177+
178+
docker run ... python:3.7-rc-alpine ...
179+
177180
\end{verbatim}
178181

182+
\pause
183+
179184
\end{frame}
180185

181186
\begin{frame}{Big benefit for everyone}

python-3.7/dataclass_example.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from dataclasses import dataclass
2+
3+
@dataclass
4+
class InventoryItem:
5+
'''Class for keeping track of an item in inventory.'''
6+
name: str
7+
unit_price: float
8+
quantity_on_hand: int = 0
9+
10+
def total_cost(self) -> float:
11+
return self.unit_price * self.quantity_on_hand
12+
13+
i = InventoryItem(name='Socks', unit_price=12.75, quantity_on_hand=14)
14+
print(f"${i.total_cost()} worth of {i.name} on hand")

python-3.7/run

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
DIR="$(cd "$(dirname -- "${0}")" && pwd)"
4+
5+
exec docker run --rm -v $DIR:/app python:3.7-rc-alpine python \
6+
/app/dataclass_example.py

0 commit comments

Comments
 (0)