With “args” vs without “args” to pass arguments to a thread in Python

This does not call test in a new thread: thread = threading.Thread(target=test(“Test”)) thread.start() Here’s how Python interprets those lines of code: Main thread calls test(“Test”). test(“Test”) returns None. Main thread calls Thread(target=None).* Main thread starts the new thread. New thread does absolutely nothing at all because its target is None. Edit: *I wondered why Thread(targe=None) … Read more

Queue.Queue vs. collections.deque

Queue.Queue and collections.deque serve different purposes. Queue.Queue is intended for allowing different threads to communicate using queued messages/data, whereas collections.deque is simply intended as a datastructure. That’s why Queue.Queue has methods like put_nowait(), get_nowait(), and join(), whereas collections.deque doesn’t. Queue.Queue isn’t intended to be used as a collection, which is why it lacks the likes … Read more