threads / dictionaries

Gerrit Holl gerrit at nl.linux.org
Wed Jan 15 16:05:32 EST 2003


.d.hos schreef op woensdag 15 januari om 21:26:36 +0000:
> can i dynamically name each dictionary for each thread? I've tried
> using the thread id as the dictionary name - but to no avail...(could
> be my coding)

You can create a class and initialize is seperately for each thread,
e.g. (untested):

class A(threads.Thread):
	def __init__(self):
		threads.Thread.__init__(self)
		self.d = {}
	
	def doSomething(self):
		self.d["lesson"] = "Italian Lesson"

yours,
Gerrit.

-- 
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/





More information about the Python-list mailing list