-1

Why in this example we must put a comma after the pat and mat argument? I searched several sites but did not find an answer

import _thread
import turtle
def f(painter):
    for i in range(3):
        painter.fd(50)
        painter.lt(60)
def g(painter):
    for i in range(3):
        painter.rt(60)
        painter.fd(50)
try:
    pat=turtle.Turtle()
    mat=turtle.Turtle()
    mat.seth(180)
    _thread.start_new_thread(f,(pat,))
    _thread.start_new_thread(g,(mat,))
    turtle.done()
except:
    pass
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Lara
  • 31
  • 6
  • Does this answer your question? [In threading.thread, why does args take a comma at the end (duplicate)](https://stackoverflow.com/q/67331204/6045800) – Tomerikoo Jul 28 '21 at 23:53

1 Answers1

0

Because its a tuple. Writing (pat) or (mat) is evaluated as part of an operation like x * (y + z). Adding the comma allows the runtime to understand you're providing a tuple or an immutable list.

BinarSkugga
  • 400
  • 2
  • 15