Last active
October 30, 2019 21:14
-
-
Save sergei-mironov/467422ce50f1e6f298d77a8447496d38 to your computer and use it in GitHub Desktop.
minimal.py
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
# Instructions | |
# 1. Load this file in IPython | |
# 2. call `run()` | |
# 3. Interrupt it with Ctrl+C | |
# 4. See no global state changed | |
from typing import Any,Optional | |
from time import sleep | |
class Model: | |
state:Any | |
def train(m:Model)->None: | |
m.state = 0 | |
print('Hit Ctrl+C to interrupt "training". Check out (the absence of) M.state') | |
while True: | |
m.state = m.state + 1 | |
print('.', end='', flush=True) | |
sleep(1) | |
M:Optional[Model]=None | |
def run(): | |
global M | |
M=Model() | |
train(M) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment