...

/

Puzzle 5: Explanation

Puzzle 5: Explanation

Let’s find out how threading works in Python.

We'll cover the following...

Let’s try it!

Try executing the code below to verify the result:

Press + to interact
from threading import Thread
from time import sleep
def printer():
for i in range(3):
print(i, end=' ')
sleep(0.1)
thr = Thread(target=printer, daemon=True) # <label id="code.daemon"/>
thr.start()
print() # Add newline

Explanation

In line 11, we start a daemon thread. Here’s what Python ...