run. , ( ), :
__init__ , . , , , , , .
:
exec('worker'+str(i)+' = Worker(tmp)')
:
exec('worker'+str(i)+'.start()')
, exec('print worker'+str(i)+'.result[0]') - , , , , , , .
:
class Worker(Process):
def process(self, x): return (x * 2) / 3
def __init__(self, list):
self.data = list
self.result = []
super(Worker, self).__init__()
def run(self):
self.result = map(self.process, self.data)
EDIT:
... , , . , , , . , , , . : . , , . , .