Python threading blues
March 20th, 2008
3 comments
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?
import threading 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:
thread = Thread.new(5) { |arg| 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.
Categories: Uncategorized
Recent Comments