Python threading blues
Posted by josh at March 20th, 2008
Some Python fan please tell me that I’m missing something.
Is this really the boilerplate necessary for creating even the simplest thread in Python?
class MyThread(threading.Thread):
def __init__(self, arg, **kwargs):
threading.Thread.__init__(self, **kwargs)
self.arg = arg
def run(self):
print "I’m running in a thread, with arg %d!" % (self.arg)
thread = MyThread(5)
thread.start()
This is making me miss Ruby, for which the equivalent is:
puts "I’m running in a thread, with arg #{arg}!"
}
P.S. Gazelle 0.2 is making a lot of progress, but unfortunately won’t hit the 1 month mark I hoped for. Surprise surprise. But when it does come, it’s going to be awesome.
There is an easier way yet…
import threading
threading.Thread(target=your_function).start()
mayowa
Fantastic, just what I wanted to see. Thanks!
josh
http://www.hokstad.com/strawman-for-a-new-parser-generator.html
…
Strawman for a new parser generator
selam