Open
Description
I often write code like:
threads = []
for i in range(10):
thread = threading.Thread(target=fn, args=(i,))
thread.start()
threads.append(thread)
for t in threads:
t.join()
and would really prefer:
threads = [threading.Thread(target=fn, args=(i,)).start() for i in range(10)]
Is there a reason why start
doesn't return self
here: https://github.com/python/cpython/blob/3.10/Lib/threading.py#L940 ?
An alternative would be to add a start: bool = False
param to the Thread
constructor such that you can construct it with start=True
. I'm not sure why you'd ever want to construct a Thread but not start it, so I wish that could default to true, but clearly it can't due to backwards compatibility.
Metadata
Metadata
Assignees
Projects
Status
No status